From: jfa Date: Wed, 4 Sep 2013 13:49:39 +0000 (+0000) Subject: Improvements for HYDRO module: 1. General mechanism for activation of GUI Geometry... X-Git-Tag: BR_hydro_v_0_3_1~142 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=bc9708cd0a4a1bae5b27ec54241d889d2e9dd486;p=modules%2Fgeom.git Improvements for HYDRO module: 1. General mechanism for activation of GUI Geometry operations. 2. Plugins mechanism in Geometry module. --- diff --git a/adm_local/cmake_files/FindGEOM.cmake b/adm_local/cmake_files/FindGEOM.cmake index 217f94034..d30118d0e 100644 --- a/adm_local/cmake_files/FindGEOM.cmake +++ b/adm_local/cmake_files/FindGEOM.cmake @@ -19,6 +19,7 @@ SET(GEOM_CXXFLAGS -I${GEOM_ROOT_DIR}/include/salome) +FIND_LIBRARY(AdvancedEngine AdvancedEngine ${GEOM_ROOT_DIR}/lib/salome) FIND_LIBRARY(AdvancedGUI AdvancedGUI ${GEOM_ROOT_DIR}/lib/salome) FIND_LIBRARY(BasicGUI BasicGUI ${GEOM_ROOT_DIR}/lib/salome) FIND_LIBRARY(BlocksGUI BlocksGUI ${GEOM_ROOT_DIR}/lib/salome) diff --git a/bin/geom_setenv.py b/bin/geom_setenv.py index 4d3702913..3132e1450 100644 --- a/bin/geom_setenv.py +++ b/bin/geom_setenv.py @@ -19,14 +19,16 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -import os +import os, sys from salome_utils import getTmpDir, generateFileName, uniteFiles -from setenv import salome_subdir +from setenv import add_path, get_lib_dir, salome_subdir # ----------------------------------------------------------------------------- def set_env( args ): """Add to the PATH-variables modules specific paths""" + psep = os.pathsep + python_version="python%d.%d" % sys.version_info[0:2] tmp_dir = getTmpDir() env_dir = generateFileName( tmp_dir, prefix="env", with_port=True ) @@ -45,3 +47,49 @@ def set_env( args ): pass pass + # find plugins + plugin_list = [] + resource_path_list = [] + for env_var in os.environ.keys(): + value = os.environ[env_var] + if env_var[-9:] == "_ROOT_DIR" and value: + plugin_root = value + plugin = env_var[:-9] # plugin name may have wrong case + + # look for NAMEOFPlugin.xml file among resource files + resource_dir = os.path.join(plugin_root,"share",salome_subdir,"resources",plugin.lower()) + if not os.access( resource_dir, os.F_OK ): continue + for resource_file in os.listdir( resource_dir ): + if not resource_file.endswith( ".xml") or \ + resource_file.lower() != plugin.lower() + ".xml": + continue + # use "name" attribute of "geom-plugin" as name of plugin in a right case + from xml.dom.minidom import parse + xml_doc = parse( os.path.join( resource_dir, resource_file )) + plugin_nodes = xml_doc.getElementsByTagName("geom-plugin") + if not plugin_nodes or not plugin_nodes[0].hasAttribute("name"): continue + plugin = plugin_nodes[0].getAttribute("name") + if plugin in plugin_list: continue + + # add paths of plugin + plugin_list.append(plugin) + if not os.environ.has_key("SALOME_"+plugin+"Resources"): + resource_path = os.path.join(plugin_root,"share",salome_subdir,"resources",plugin.lower()) + os.environ["SALOME_"+plugin+"Resources"] = resource_path + resource_path_list.append( resource_path ) + add_path(os.path.join(plugin_root,get_lib_dir(),python_version, "site-packages",salome_subdir), "PYTHONPATH") + add_path(os.path.join(plugin_root,get_lib_dir(),salome_subdir), "PYTHONPATH") + + if sys.platform == "win32": + add_path(os.path.join(plugin_root,get_lib_dir(),salome_subdir), "PATH") + add_path(os.path.join(plugin_root,"bin",salome_subdir), "PYTHONPATH") + else: + add_path(os.path.join(plugin_root,get_lib_dir(),salome_subdir), "LD_LIBRARY_PATH") + add_path(os.path.join(plugin_root,"bin",salome_subdir), "PYTHONPATH") + add_path(os.path.join(plugin_root,"bin",salome_subdir), "PATH") + pass + pass + break + plugin_list.append("GEOMActions") + os.environ["GEOM_PluginsList"] = ":".join(plugin_list) + os.environ["SalomeAppConfig"] = os.environ["SalomeAppConfig"] + psep + psep.join(resource_path_list) diff --git a/configure.ac b/configure.ac index bb1e8d656..af06e2955 100644 --- a/configure.ac +++ b/configure.ac @@ -489,6 +489,7 @@ AC_OUTPUT([ \ doc/salome/tui/static/header.html \ src/Makefile \ src/AdvancedGUI/Makefile \ + src/AdvancedEngine/Makefile \ src/ARCHIMEDE/Makefile \ src/BREPExport/Makefile \ src/BREPImport/Makefile \ diff --git a/idl/GEOM_Gen.idl b/idl/GEOM_Gen.idl index 23083c1f4..7aaaa622c 100644 --- a/idl/GEOM_Gen.idl +++ b/idl/GEOM_Gen.idl @@ -4563,8 +4563,8 @@ module GEOM in boolean theInheritFirstArg, in boolean theAddPrefix); - // # Methods to access interfaces for objects creation and transformation - + // # Methods to access interfaces for objects creation and transformation + GEOM_IBasicOperations GetIBasicOperations (in long theStudyID) raises (SALOME::SALOME_Exception); GEOM_ITransformOperations GetITransformOperations(in long theStudyID) raises (SALOME::SALOME_Exception); GEOM_I3DPrimOperations GetI3DPrimOperations (in long theStudyID) raises (SALOME::SALOME_Exception); @@ -4577,10 +4577,12 @@ module GEOM GEOM_IMeasureOperations GetIMeasureOperations (in long theStudyID) raises (SALOME::SALOME_Exception); GEOM_IBlocksOperations GetIBlocksOperations (in long theStudyID) raises (SALOME::SALOME_Exception); GEOM_IGroupOperations GetIGroupOperations (in long theStudyID) raises (SALOME::SALOME_Exception); - GEOM_IAdvancedOperations GetIAdvancedOperations (in long theStudyID) raises (SALOME::SALOME_Exception); - // # Objects Management - + GEOM_IOperations GetPluginOperations (in long theStudyID, + in string theLibName) raises (SALOME::SALOME_Exception); + + // # Objects Management + /*! * \brief Removes the object from the GEOM component diff --git a/resources/GEOMActions.xml b/resources/GEOMActions.xml new file mode 100644 index 000000000..a59fcbbc2 --- /dev/null +++ b/resources/GEOMActions.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/Makefile.am b/resources/Makefile.am index 90ca30a67..0fd04dc92 100644 --- a/resources/Makefile.am +++ b/resources/Makefile.am @@ -25,6 +25,7 @@ include $(top_srcdir)/adm_local/unix/make_common_starter.am dist_salomeres_DATA = \ +GEOMActions.xml \ GEOM_en.xml \ GEOM_fr.xml \ GEOM.config \ diff --git a/resources/SalomeApp.xml.in b/resources/SalomeApp.xml.in index fbd07f25b..6f5be593d 100644 --- a/resources/SalomeApp.xml.in +++ b/resources/SalomeApp.xml.in @@ -37,6 +37,7 @@
+
diff --git a/src/AdvancedEngine/AdvancedEngine.cxx b/src/AdvancedEngine/AdvancedEngine.cxx new file mode 100644 index 000000000..bd5356b33 --- /dev/null +++ b/src/AdvancedEngine/AdvancedEngine.cxx @@ -0,0 +1,43 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com + +#include "GEOM_AdvancedEngine.hxx" + +#include "AdvancedEngine_OperationsCreator.hh" + +//============================================================================= +/*! + * + */ +//============================================================================= + +extern "C" +{ +ADVANCEDENGINE_EXPORT + GEOM_GenericOperationsCreator* GetOperationsCreator() + { + //MESSAGE("GetOperationsCreator"); + + AdvancedEngine_OperationsCreator* aCreator = new AdvancedEngine_OperationsCreator(); + + return aCreator; + } +} diff --git a/src/AdvancedEngine/AdvancedEngine_OperationsCreator.cc b/src/AdvancedEngine/AdvancedEngine_OperationsCreator.cc new file mode 100644 index 000000000..811c480b6 --- /dev/null +++ b/src/AdvancedEngine/AdvancedEngine_OperationsCreator.cc @@ -0,0 +1,72 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com + +#include "GEOM_AdvancedEngine.hxx" + +#include "AdvancedEngine_OperationsCreator.hh" + +#include "GEOM_IAdvancedOperations_i.hh" + +// Operations +#include +#include +// #include +#include +/*@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@*/ + +#include +#include + +#include "Utils_ExceptHandlers.hxx" +#include "utilities.h" + +//============================================================================ +// function : Create +// purpose : +//============================================================================ +GEOM_IOperations_i* AdvancedEngine_OperationsCreator::Create (PortableServer::POA_ptr thePOA, + int theStudyId, + GEOM::GEOM_Gen_ptr theEngine, + ::GEOMImpl_Gen* theGenImpl) +{ + Unexpect aCatch(SALOME_SalomeException); + MESSAGE( "AdvancedEngine_OperationsCreator::Create" ); + + if (_mapOfOperations.find(theStudyId) == _mapOfOperations.end()) { + _mapOfOperations[theStudyId] = new GEOMImpl_IAdvancedOperations (theGenImpl, theStudyId); + + // Advanced operations + TFunction_DriverTable::Get()->AddDriver(GEOMImpl_PipeTShapeDriver::GetID(), + new GEOMImpl_PipeTShapeDriver()); + TFunction_DriverTable::Get()->AddDriver(GEOMImpl_DividedDiskDriver::GetID(), + new GEOMImpl_DividedDiskDriver()); + //TFunction_DriverTable::Get()->AddDriver(GEOMImpl_DividedCylinderDriver::GetID(), + // new GEOMImpl_DividedCylinderDriver()); + TFunction_DriverTable::Get()->AddDriver(GEOMImpl_SmoothingSurfaceDriver::GetID(), + new GEOMImpl_SmoothingSurfaceDriver()); + /*@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@*/ + } + + GEOM_IAdvancedOperations_i* aServant = + new GEOM_IAdvancedOperations_i (thePOA, theEngine, _mapOfOperations[theStudyId]); + + return aServant; +} diff --git a/src/AdvancedEngine/AdvancedEngine_OperationsCreator.hh b/src/AdvancedEngine/AdvancedEngine_OperationsCreator.hh new file mode 100755 index 000000000..098dc8faf --- /dev/null +++ b/src/AdvancedEngine/AdvancedEngine_OperationsCreator.hh @@ -0,0 +1,51 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com + +#ifndef _GEOM_ADVANCEDENGINE_OPERATIONSCREATOR_HXX_ +#define _GEOM_ADVANCEDENGINE_OPERATIONSCREATOR_HXX_ + +#include "GEOM_AdvancedEngine.hxx" + +#include "GEOM_Gen_i.hh" + +#include "GEOMImpl_IAdvancedOperations.hxx" + +#include + +//===================================================================== +// Operations creator +//===================================================================== +class ADVANCEDENGINE_EXPORT AdvancedEngine_OperationsCreator : public GEOM_GenericOperationsCreator +{ + public: + // Create operations + virtual GEOM_IOperations_i* Create (PortableServer::POA_ptr thePOA, + int theStudyId, + GEOM::GEOM_Gen_ptr theEngine, + ::GEOMImpl_Gen* theGenImpl); + // return the name of IDL module + //virtual std::string GetModuleName(); + + private: + std::map _mapOfOperations; +}; + +#endif diff --git a/src/AdvancedEngine/AdvancedEngine_Types.hxx b/src/AdvancedEngine/AdvancedEngine_Types.hxx new file mode 100644 index 000000000..aae00cda0 --- /dev/null +++ b/src/AdvancedEngine/AdvancedEngine_Types.hxx @@ -0,0 +1,37 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com + +// Advanced functions (base = 200) +#define ADVANCED_BASE 200 // NO OPERATION (advanced operations base) +#define GEOM_TSHAPE 201 +#define GEOM_DIVIDEDDISK 202 +#define GEOM_DIVIDEDCYLINDER 203 +#define GEOM_SMOOTHINGSURFACE 204 +/*@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@*/ +// Advanced functions sub-operations codes +#define TSHAPE_BASIC 1 +#define TSHAPE_CHAMFER 2 +#define TSHAPE_FILLET 3 +#define DIVIDEDDISK_R_RATIO 1 +#define DIVIDEDDISK_R_VECTOR_PNT 2 +#define DIVIDEDCYLINDER_R_H 1 +#define SMOOTHINGSURFACE_LPOINTS 1 +/*@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@*/ diff --git a/src/AdvancedEngine/GEOMImpl_DividedDiskDriver.cxx b/src/AdvancedEngine/GEOMImpl_DividedDiskDriver.cxx new file mode 100644 index 000000000..d44566c2f --- /dev/null +++ b/src/AdvancedEngine/GEOMImpl_DividedDiskDriver.cxx @@ -0,0 +1,528 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com + +#include + +#include "AdvancedEngine_Types.hxx" + +#include +#include +#include +#include + +// OCCT includes +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +#include +#include + +#include + +#include +//@@ include required header files here @@// + +enum +{ + SQUARE, + HEXAGON +}; +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& GEOMImpl_DividedDiskDriver::GetID() +{ + static Standard_GUID aGUID("0b01da9a-c5da-11e1-8d80-78e7d1879630"); + return aGUID; +} + +//======================================================================= +//function : GEOMImpl_DividedDiskDriver +//purpose : +//======================================================================= +GEOMImpl_DividedDiskDriver::GEOMImpl_DividedDiskDriver() +{ +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_DividedDiskDriver::Execute(TFunction_Logbook& log) const +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); + + GEOMImpl_IDividedDisk aData (aFunction); + Standard_Integer aType = aFunction->GetType(); + + TopoDS_Shape aShape; + + // Getting data + double R = aData.GetR(); + double Ratio = aData.GetRatio(); + int Pattern = aData.GetType(); + + // Build reference disk (in the global coordinate system) + TopoDS_Shape aDisk; + + if (Pattern == SQUARE) + aDisk = MakeDiskSquare( R, Ratio ); + else if (Pattern == HEXAGON) + aDisk = MakeDiskHexagon( R, Ratio ); + + if (aType == DIVIDEDDISK_R_RATIO) + { + int theOrientation = aData.GetOrientation(); + aShape = TransformShape(aDisk, theOrientation); + } + else if (aType == DIVIDEDDISK_R_VECTOR_PNT) + { + Handle(GEOM_Function) aRefPoint = aData.GetCenter(); + Handle(GEOM_Function) aRefVector = aData.GetVector(); + TopoDS_Shape aShapePnt = aRefPoint->GetValue(); + TopoDS_Shape aShapeVec = aRefVector->GetValue(); + + if (aShapePnt.ShapeType() == TopAbs_VERTEX && + aShapeVec.ShapeType() == TopAbs_EDGE) + { + gp_Pnt aPnt = BRep_Tool::Pnt(TopoDS::Vertex(aShapePnt)); + TopoDS_Edge anE = TopoDS::Edge(aShapeVec); + TopoDS_Vertex V1, V2; + TopExp::Vertices(anE, V1, V2, Standard_True); + if (!V1.IsNull() && !V2.IsNull()) + { + gp_Vec aVec (BRep_Tool::Pnt(V1), BRep_Tool::Pnt(V2)); + gp_Dir aDir(aVec); + aShape = TransformShape(aDisk, aPnt, aDir); + } + } + } + + if (aShape.IsNull()) return 0; + + aFunction->SetValue(aShape); + + log.SetTouched(Label()); + + return 1; +} + + +//======================================================================= +//function : MakeDiskHexagon +//purpose : +//======================================================================= +TopoDS_Shell GEOMImpl_DividedDiskDriver::MakeDiskHexagon(double R, double Ratio) const +{ + // Geometry + gp_Dir ZDir(0,0,1); + gp_Dir XDir(1,0,0); + gp_Pnt Orig(0,0,0); + + // Circle + gp_Ax1 Ax1(Orig,ZDir); + gp_Ax2 Ax(Orig,ZDir,XDir); + gp_Circ aCircle(Ax, R); + + // Points +// gp_Pnt P4(0.01*Ratio*R,0,0); +// gp_Pnt P3(R,0,0); +// gp_Pnt P2 = P3.Rotated(Ax1,-M_PI/6.0); +// gp_Pnt P1(P4.X(), +// P4.X()/sqrt(3.0),0); + gp_Pnt P1(0.01*Ratio*R*sqrt(3.0)/2,0,0); + gp_Pnt P2(R,0,0); + gp_Pnt P3 = P2.Rotated(Ax1,M_PI/6.0); + gp_Pnt P4(P1.X(), + P1.X()/sqrt(3.0),0); + + + //surfaces + gp_Ax2 anAx (gp::XOY()); + Handle(Geom_Plane) aPlane = new Geom_Plane (anAx); + + // Topology + + // Vertices + TopoDS_Vertex O = BRepBuilderAPI_MakeVertex(Orig); + TopoDS_Vertex V1_init = BRepBuilderAPI_MakeVertex(P1); + TopoDS_Vertex V2_init = BRepBuilderAPI_MakeVertex(P2); + TopoDS_Vertex V3 = BRepBuilderAPI_MakeVertex(P3); + TopoDS_Vertex V4 = BRepBuilderAPI_MakeVertex(P4); + + TopoDS_Vertex V1 = V1_init; + TopoDS_Vertex V2 = V2_init; + + //Rotation + gp_Trsf myTrsf; + myTrsf.SetRotation(Ax1, M_PI/3.0); + + BRepBuilderAPI_Transform xform(myTrsf); + xform.Perform(V1,Standard_True); + TopoDS_Vertex V1_60 = TopoDS::Vertex(xform.Shape()); + xform.Perform(V2,Standard_True); + TopoDS_Vertex V2_60 = TopoDS::Vertex(xform.Shape()); + + // Declaration of shapes (used in the loop) + TopoDS_Edge E1, E2, E3, E4, E5, E6, E7, E8, E9; + TopoDS_Wire W1, W2, W3; + TopoDS_Face F1, F2, F3; + TopoDS_Shell S; + + BRep_Builder aBuilder; + aBuilder.MakeShell(S); + + // Initialisation of edges + TopoDS_Edge E1_init = BRepBuilderAPI_MakeEdge(V1,TopoDS::Vertex(V2.Reversed())); + E1 = E1_init; + TopoDS_Edge E8_init = BRepBuilderAPI_MakeEdge(O,TopoDS::Vertex(V1.Reversed())); + E8 = E8_init; + + for (int i=1;i<=6;i++) + { + // Edges + + // for Face1 + E2 = BRepBuilderAPI_MakeEdge(aCircle, V2, TopoDS::Vertex(V3.Reversed())); + E3 = BRepBuilderAPI_MakeEdge(V3,TopoDS::Vertex(V4.Reversed())); + E4 = BRepBuilderAPI_MakeEdge(V4,TopoDS::Vertex(V1.Reversed())); + + // for Face2 + if (i==6) + { + E5 = BRepBuilderAPI_MakeEdge(aCircle, V3, TopoDS::Vertex(V2_init.Reversed())); + E7 = BRepBuilderAPI_MakeEdge(V1_init,TopoDS::Vertex(V4.Reversed())); + } + else + { + E5 = BRepBuilderAPI_MakeEdge(aCircle, V3, TopoDS::Vertex(V2_60.Reversed())); + E7 = BRepBuilderAPI_MakeEdge(V1_60,TopoDS::Vertex(V4.Reversed())); + } + E6 = BRepBuilderAPI_MakeEdge(V2_60,TopoDS::Vertex(V1_60.Reversed())); + + // for Face3 + E9 = BRepBuilderAPI_MakeEdge(V1_60,TopoDS::Vertex(O.Reversed())); + + + // Wires + + //Wire1 + aBuilder.MakeWire(W1); + if (i==1) + aBuilder.Add(W1,E1); + else + aBuilder.Add(W1,TopoDS::Edge(E1.Reversed())); + aBuilder.Add(W1,E2); + aBuilder.Add(W1,E3); + aBuilder.Add(W1,E4); + + // Wire 2 + aBuilder.MakeWire(W2); + aBuilder.Add(W2,TopoDS::Edge(E3.Reversed())); + aBuilder.Add(W2,E5); + if (i==6) + aBuilder.Add(W2,TopoDS::Edge(E1_init.Reversed())); + else + aBuilder.Add(W2,E6); + aBuilder.Add(W2,E7); + + // Wire3 + aBuilder.MakeWire(W3); + if (i==1) + aBuilder.Add(W3,E8); + else + aBuilder.Add(W3,TopoDS::Edge(E8.Reversed())); + aBuilder.Add(W3,TopoDS::Edge(E4.Reversed())); + aBuilder.Add(W3,TopoDS::Edge(E7.Reversed())); + if (i==6) + aBuilder.Add(W3,TopoDS::Edge(E8_init.Reversed())); + else + aBuilder.Add(W3,E9); + + // Faces creation + F1 = BRepBuilderAPI_MakeFace(aPlane,W1); + F2 = BRepBuilderAPI_MakeFace(aPlane,W2); + F3 = BRepBuilderAPI_MakeFace(aPlane,W3); + + //Shell + aBuilder.Add(S, F1); + aBuilder.Add(S, F2); + aBuilder.Add(S, F3); + + // rotation + V1=V1_60; + V2=V2_60; + + xform.Perform(V1_60,Standard_True); + V1_60 = TopoDS::Vertex(xform.Shape()); + xform.Perform(V2_60,Standard_True); + V2_60 = TopoDS::Vertex(xform.Shape()); + xform.Perform(V3,Standard_True); + V3 = TopoDS::Vertex(xform.Shape()); + xform.Perform(V4,Standard_True); + V4 = TopoDS::Vertex(xform.Shape()); + + // "Increment" of edges + E1=E6; + E8=E9; + } + + return S; +} + +//======================================================================= +//function : MakeDiskSquare +//purpose : +//======================================================================= +TopoDS_Shape GEOMImpl_DividedDiskDriver::MakeDiskSquare(double R, double Ratio) const +{ + // Geometry + gp_Dir ZDir(0,0,1); + gp_Dir XDir(1,0,0); + gp_Pnt Orig(0,0,0); + + // Circle + gp_Ax1 Ax1(Orig,ZDir); + gp_Ax2 Ax(Orig,ZDir,XDir); + gp_Circ aCircle(Ax, R); + + // Points + gp_Pnt P1(0.01*Ratio*R,0,0); + gp_Pnt P2(R,0,0); + + //surfaces + gp_Ax2 anAx (gp::XOY()); + Handle(Geom_Plane) aPlane = new Geom_Plane (anAx); + + // Topology + + // Vertices + TopoDS_Vertex V1_init = BRepBuilderAPI_MakeVertex(P1); + TopoDS_Vertex V2_init = BRepBuilderAPI_MakeVertex(P2); + + TopoDS_Vertex V1 = V1_init; + TopoDS_Vertex V2 = V2_init; + + //Rotation + gp_Trsf myTrsf; + myTrsf.SetRotation(Ax1, M_PI/2); + + BRepBuilderAPI_Transform xform(myTrsf); + xform.Perform(V1,Standard_True); + TopoDS_Vertex V1_rotated = TopoDS::Vertex(xform.Shape()); + xform.Perform(V2,Standard_True); + TopoDS_Vertex V2_rotated = TopoDS::Vertex(xform.Shape()); + + // Declaration of shapes (used in the loop) + TopoDS_Edge E1, E2, E3, E4; + TopoDS_Wire W1, W2; + TopoDS_Face F1, F2; + TopoDS_Shell S; + + BRep_Builder aBuilder; + aBuilder.MakeWire(W2); // Central Wire + aBuilder.MakeShell(S); // Shell + + // Initialisation of edges + TopoDS_Edge E1_init = BRepBuilderAPI_MakeEdge(V1,TopoDS::Vertex(V2.Reversed())); + E1 = E1_init; + + for (int i=1;i<=4;i++) + { + // Edges + // for Face1 + + E3 = BRepBuilderAPI_MakeEdge(V2_rotated,TopoDS::Vertex(V1_rotated.Reversed())); + if (i == 4) + { + E2 = BRepBuilderAPI_MakeEdge(aCircle, V2, TopoDS::Vertex(V2_init.Reversed())); + E4 = BRepBuilderAPI_MakeEdge(V1_init,TopoDS::Vertex(V1.Reversed())); + } + else + { + E2 = BRepBuilderAPI_MakeEdge(aCircle, V2, TopoDS::Vertex(V2_rotated.Reversed())); + E4 = BRepBuilderAPI_MakeEdge(V1_rotated,TopoDS::Vertex(V1.Reversed())); + } + + // Wires + //Wire1 + aBuilder.MakeWire(W1); + if (i==1) + aBuilder.Add(W1,E1); + else + aBuilder.Add(W1,TopoDS::Edge(E1.Reversed())); + aBuilder.Add(W1,E2); + if (i==4) + aBuilder.Add(W1,TopoDS::Edge(E1_init.Reversed())); + else + aBuilder.Add(W1,E3); + aBuilder.Add(W1,E4); + + // Wire central + aBuilder.Add(W2,TopoDS::Edge(E4.Reversed())); + + // Faces creation + F1 = BRepBuilderAPI_MakeFace(aPlane,W1); + + //Shell + aBuilder.Add(S, F1); + + // rotation + V1=V1_rotated; + V2=V2_rotated; + + xform.Perform(V1_rotated,Standard_True); + V1_rotated = TopoDS::Vertex(xform.Shape()); + xform.Perform(V2_rotated,Standard_True); + V2_rotated = TopoDS::Vertex(xform.Shape()); + + // "Increment" of edges + E1=E3; + } + // Central square Face + F2 = BRepBuilderAPI_MakeFace(aPlane,W2); + aBuilder.Add(S, F2); + + return S; +} + + +//======================================================================= +//function : TrasformShape(TopoDS_Shape aShape,int theOrientation) +//purpose : Perform shape transformation accordingly with specified +// orientation +//======================================================================= +TopoDS_Shape GEOMImpl_DividedDiskDriver::TransformShape(TopoDS_Shape theShape, int theOrientation) const +{ + gp_Dir N, Vx; + gp_Pnt theOrigin = gp::Origin(); + + switch(theOrientation) + { + case 1: + { + N = gp::DZ(); + Vx = gp::DX(); + break; + } + case 2: + { + N = gp::DX(); + Vx = gp::DY(); + break; + } + case 3: + { + N = gp::DY(); + Vx = gp::DZ(); + break; + } + } + + gp_Ax3 aWPlane = gp_Ax3(theOrigin, N, Vx); + + return WPlaneTransform(theShape, aWPlane); +} + +//======================================================================= +//function : TrasformShape(TopoDS_Shape aShape, gp_Dir V, gp_Pnt P) +//purpose : Perform shape transformation accordingly with specified +// pnt and direction +//======================================================================= +TopoDS_Shape GEOMImpl_DividedDiskDriver::TransformShape(TopoDS_Shape theShape, gp_Pnt P, gp_Dir V) const +{ + gp_Ax3 aWPlane( P, V ); + return WPlaneTransform(theShape, aWPlane); +} + +//======================================================================= +//function : WPlaneTransform +//purpose : Perform shape transformation accordingly with the given +// Working Plane +//======================================================================= +TopoDS_Shape GEOMImpl_DividedDiskDriver::WPlaneTransform(TopoDS_Shape theShape, gp_Ax3 theWPlane) const +{ + gp_Trsf aTrans; + aTrans.SetTransformation(theWPlane); + aTrans.Invert(); + BRepBuilderAPI_Transform aTransformation (theShape, aTrans, Standard_False); + return aTransformation.Shape(); +} + +//================================================================================ +/*! + * \brief Returns a name of creation operation and names and values of creation parameters + */ +//================================================================================ + +bool GEOMImpl_DividedDiskDriver:: +GetCreationInformation(std::string& theOperationName, + std::vector& theParams) +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) function = GEOM_Function::GetFunction(Label()); + + GEOMImpl_IDividedDisk aCI( function ); + Standard_Integer aType = function->GetType(); + + theOperationName = "DIVIDEDDISK"; + + switch ( aType ) { + case DIVIDEDDISK_R_RATIO: + AddParam( theParams, "Radius", aCI.GetR() ); + AddParam( theParams, "Ratio", aCI.GetRatio() ); + AddParam( theParams, "Orientation", aCI.GetOrientation() ); + AddParam( theParams, "Division pattern", aCI.GetType() ); + break; + case DIVIDEDDISK_R_VECTOR_PNT: + AddParam( theParams, "Center Point", aCI.GetCenter() ); + AddParam( theParams, "Vector", aCI.GetVector() ); + AddParam( theParams, "Radius", aCI.GetR() ); + AddParam( theParams, "Division pattern", aCI.GetType() ); + break; + default: + return false; + } + + return true; +} + +IMPLEMENT_STANDARD_HANDLE (GEOMImpl_DividedDiskDriver,GEOM_BaseDriver); +IMPLEMENT_STANDARD_RTTIEXT (GEOMImpl_DividedDiskDriver,GEOM_BaseDriver); diff --git a/src/AdvancedEngine/GEOMImpl_DividedDiskDriver.hxx b/src/AdvancedEngine/GEOMImpl_DividedDiskDriver.hxx new file mode 100644 index 000000000..8f6755a80 --- /dev/null +++ b/src/AdvancedEngine/GEOMImpl_DividedDiskDriver.hxx @@ -0,0 +1,67 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef _GEOMImpl_DividedDiskDriver_HXX +#define _GEOMImpl_DividedDiskDriver_HXX + +#include + +class Handle_Standard_Type; +class GEOMImpl_DividedDiskDriver; +class TopoDS_Shape; +class TopoDS_Shell; +class gp_Pnt; +class gp_Dir; +class gp_Ax3; + +#include "GEOM_BaseDriver.hxx" + +DEFINE_STANDARD_HANDLE( GEOMImpl_DividedDiskDriver, GEOM_BaseDriver ); + +class GEOMImpl_DividedDiskDriver : public GEOM_BaseDriver { +public: + // Methods PUBLIC + // + Standard_EXPORT GEOMImpl_DividedDiskDriver(); + Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const; + Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {} + Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const + { + return Standard_True; + } + Standard_EXPORT static const Standard_GUID& GetID(); + Standard_EXPORT ~GEOMImpl_DividedDiskDriver() {}; + + Standard_EXPORT virtual + bool GetCreationInformation(std::string& theOperationName, + std::vector& params); +private: + TopoDS_Shape TransformShape (TopoDS_Shape aShape, int theOrientation) const; + TopoDS_Shape TransformShape (TopoDS_Shape aShape, gp_Pnt P, gp_Dir V) const; + TopoDS_Shape WPlaneTransform (TopoDS_Shape aShape, gp_Ax3 theWPlane) const; + TopoDS_Shell MakeDiskHexagon (double R, double Ratio) const; + TopoDS_Shape MakeDiskSquare (double R, double Ratio) const; + + DEFINE_STANDARD_RTTI( GEOMImpl_DividedDiskDriver ) +}; + +#endif // _GEOMImpl_DividedDiskDriver_HXX diff --git a/src/AdvancedEngine/GEOMImpl_IAdvancedOperations.cxx b/src/AdvancedEngine/GEOMImpl_IAdvancedOperations.cxx new file mode 100644 index 000000000..4e07fb95d --- /dev/null +++ b/src/AdvancedEngine/GEOMImpl_IAdvancedOperations.cxx @@ -0,0 +1,3474 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : GEOMImpl_IAdvancedOperations.cxx +// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) + +#include "GEOMImpl_IAdvancedOperations.hxx" + +#include + +#include +#include +#include + +#include "GEOM_Function.hxx" +#include "GEOM_PythonDump.hxx" +#include "GEOMUtils.hxx" +#include "GEOMAlgo_Splitter.hxx" +#include "GEOMAlgo_FinderShapeOn1.hxx" + +#include "GEOMImpl_Gen.hxx" +#include "GEOMImpl_Types.hxx" + +#include "GEOMImpl_IBasicOperations.hxx" +#include "GEOMImpl_IBooleanOperations.hxx" +#include "GEOMImpl_IShapesOperations.hxx" +#include "GEOMImpl_ITransformOperations.hxx" +#include "GEOMImpl_IBlocksOperations.hxx" +#include "GEOMImpl_I3DPrimOperations.hxx" +#include "GEOMImpl_ILocalOperations.hxx" +#include "GEOMImpl_IHealingOperations.hxx" +#include "GEOMImpl_IGroupOperations.hxx" + +#include "GEOMImpl_GlueDriver.hxx" +#include "GEOMImpl_PipeTShapeDriver.hxx" +#include "GEOMImpl_IPipeTShape.hxx" +#include "GEOMImpl_DividedDiskDriver.hxx" +#include "GEOMImpl_IDividedDisk.hxx" +// #include "GEOMImpl_DividedCylinderDriver.hxx" +// #include "GEOMImpl_IDividedCylinder.hxx" +#include +#include +/*@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@*/ + +#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 "AdvancedEngine_Types.hxx" + +#include +#include +#include +#include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC + +#define HALF_LENGTH_MAIN_PIPE "Main pipe half length" //"Tuyau principal - demi longueur" +#define HALF_LENGTH_INCIDENT_PIPE "Incident pipe half length" //"Tuyau incident - demi longueur" +#define CIRCULAR_QUARTER_PIPE "Circular quarter of pipe" //"Circulaire - quart de tuyau" +#define THICKNESS "Thickness" //"Epaisseur" +#define FLANGE "Flange" // "Collerette" +#define CHAMFER_OR_FILLET "Chamfer or fillet" //"Chanfrein ou Raccord" +#define JUNCTION_FACE_1 "Junction 1" //"Face de jonction 1" +#define JUNCTION_FACE_2 "Junction 2" //"Face de jonction 2" +#define JUNCTION_FACE_3 "Junction 3" //"Face de jonction 3" + +#define FIND_GROUPS_BY_POINTS 1 + +//============================================================================= +/*! + * Constructor + */ +//============================================================================= +GEOMImpl_IAdvancedOperations::GEOMImpl_IAdvancedOperations(GEOM_Engine* theEngine, int theDocID) : + GEOM_IOperations(theEngine, theDocID) +{ + MESSAGE("GEOMImpl_IAdvancedOperations::GEOMImpl_IAdvancedOperations"); + myBasicOperations = new GEOMImpl_IBasicOperations(GetEngine(), GetDocID()); + myBooleanOperations = new GEOMImpl_IBooleanOperations(GetEngine(), GetDocID()); + myShapesOperations = new GEOMImpl_IShapesOperations(GetEngine(), GetDocID()); + myTransformOperations = new GEOMImpl_ITransformOperations(GetEngine(), GetDocID()); + myBlocksOperations = new GEOMImpl_IBlocksOperations(GetEngine(), GetDocID()); + my3DPrimOperations = new GEOMImpl_I3DPrimOperations(GetEngine(), GetDocID()); + myLocalOperations = new GEOMImpl_ILocalOperations(GetEngine(), GetDocID()); + myHealingOperations = new GEOMImpl_IHealingOperations(GetEngine(), GetDocID()); + myGroupOperations = new GEOMImpl_IGroupOperations(GetEngine(), GetDocID()); +} + +//============================================================================= +/*! + * Destructor + */ +//============================================================================= +GEOMImpl_IAdvancedOperations::~GEOMImpl_IAdvancedOperations() +{ + MESSAGE("GEOMImpl_IAdvancedOperations::~GEOMImpl_IAdvancedOperations"); + delete myBasicOperations; + delete myBooleanOperations; + delete myShapesOperations; + delete myTransformOperations; + delete myBlocksOperations; + delete my3DPrimOperations; + delete myLocalOperations; + delete myHealingOperations; + delete myGroupOperations; +} + +//============================================================================= +/*! + * SetPosition + */ +//============================================================================= +gp_Trsf GEOMImpl_IAdvancedOperations::GetPositionTrsf(double theL1, double theL2, + Handle(GEOM_Object) theP1, + Handle(GEOM_Object) theP2, + Handle(GEOM_Object) theP3) +{ + // Old Local Coordinates System oldLCS + gp_Pnt P0(0, 0, 0); + gp_Pnt P1(-theL1, 0, 0); + gp_Pnt P2(theL1, 0, 0); + gp_Pnt P3(0, 0, theL2); + + gp_Dir oldX(gp_Vec(P1, P2)); + gp_Dir oldZ(gp_Vec(P0, P3)); + gp_Ax3 oldLCS(P0, oldZ, oldX); + + // New Local Coordinates System newLCS + double LocX, LocY, LocZ; + gp_Pnt newP1 = BRep_Tool::Pnt(TopoDS::Vertex(theP1->GetValue())); + gp_Pnt newP2 = BRep_Tool::Pnt(TopoDS::Vertex(theP2->GetValue())); + gp_Pnt newP3 = BRep_Tool::Pnt(TopoDS::Vertex(theP3->GetValue())); + LocX = (newP1.X() + newP2.X()) / 2.; + LocY = (newP1.Y() + newP2.Y()) / 2.; + LocZ = (newP1.Z() + newP2.Z()) / 2.; + gp_Pnt newO(LocX, LocY, LocZ); + + gp_Dir newX(gp_Vec(newP1, newP2)); // P1P2 Vector + gp_Dir newZ(gp_Vec(newO, newP3)); // OP3 Vector + gp_Ax3 newLCS = gp_Ax3(newO, newZ, newX); + + gp_Trsf aTrsf; + aTrsf.SetDisplacement(oldLCS, newLCS); + + return aTrsf; +} + +//============================================================================= +/*! + * CheckCompatiblePosition + * + */ +//============================================================================= +bool GEOMImpl_IAdvancedOperations::CheckCompatiblePosition(double& theL1, double& theL2, + Handle(GEOM_Object) theP1, + Handle(GEOM_Object) theP2, + Handle(GEOM_Object) theP3, + double theTolerance) +{ + SetErrorCode(KO); + gp_Pnt P1 = BRep_Tool::Pnt(TopoDS::Vertex(theP1->GetValue())); + gp_Pnt P2 = BRep_Tool::Pnt(TopoDS::Vertex(theP2->GetValue())); + gp_Pnt P3 = BRep_Tool::Pnt(TopoDS::Vertex(theP3->GetValue())); + + double d12 = P1.Distance(P2); + double d13 = P1.Distance(P3); + double d23 = P2.Distance(P3); + // double d2 = newO.Distance(P3); + + if (Abs(d12) <= Precision::Confusion()) { + SetErrorCode("Junctions points P1 and P2 are identical"); + return false; + } + if (Abs(d13) <= Precision::Confusion()) { + SetErrorCode("Junctions points P1 and P3 are identical"); + return false; + } + if (Abs(d23) <= Precision::Confusion()) { + SetErrorCode("Junctions points P2 and P3 are identical"); + return false; + } + + + double newL1 = 0.5 * d12; + double newL2 = sqrt(pow(d13,2)-pow(newL1,2)); + // + // theL1*(1-theTolerance) <= newL1 <= theL1*(1+theTolerance) + // + if (fabs(newL1 - theL1) > Precision::Approximation()) { + if ( (newL1 * (1 - theTolerance) -theL1 <= Precision::Approximation()) && + (newL1 * (1 + theTolerance) -theL1 >= Precision::Approximation()) ) { + // std::cerr << "theL1 = newL1" << std::endl; + theL1 = newL1; + } else { + theL1 = -1; + SetErrorCode("Dimension for main pipe (L1) is incompatible with new position"); + return false; + } + } + + // + // theL2*(1-theTolerance) <= newL2 <= theL2*(1+theTolerance) + // + if (fabs(newL2 - theL2) > Precision::Approximation()) { + if ( (newL2 * (1 - theTolerance) -theL2 <= Precision::Approximation()) && + (newL2 * (1 + theTolerance) -theL2 >= Precision::Approximation()) ) { + theL2 = newL2; + } else { + theL2 = -1; + SetErrorCode("Dimension for incident pipe (L2) is incompatible with new position"); + return false; + } + } + + SetErrorCode(OK); + return true; + +} + +//============================================================================= +/*! + * Generate the propagation groups of a Pipe T-Shape used for hexa mesh + */ +//============================================================================= +bool GEOMImpl_IAdvancedOperations::MakeGroups(Handle(GEOM_Object) theShape, int shapeType, + double theR1, double theW1, double theL1, + double theR2, double theW2, double theL2, + double theH, double theW, double theRF, + Handle(TColStd_HSequenceOfTransient) theSeq, + gp_Trsf aTrsf) +{ + SetErrorCode(KO); + + if (theShape.IsNull()) return false; + + TopoDS_Shape aShape = theShape->GetValue(); + if (aShape.IsNull()) { + SetErrorCode("Shape is not defined"); + return false; + } + + gp_Trsf aTrsfInv = aTrsf.Inverted(); + +// int expectedGroups = 0; +// if (shapeType == TSHAPE_BASIC) +// if (Abs(theR2+theW2-theR1-theW1) <= Precision::Approximation()) +// expectedGroups = 10; +// else +// expectedGroups = 11; +// else if (shapeType == TSHAPE_CHAMFER || shapeType == TSHAPE_FILLET) +// expectedGroups = 12; + + double aR1Ext = theR1 + theW1; + double aR2Ext = theR2 + theW2; + + ///////////////////////// + //// Groups of Faces //// + ///////////////////////// + + // + // Comment the following lines when GetInPlace bug is solved + // == BEGIN + // Workaround of GetInPlace bug + // Create a bounding box that fits the shape + Handle(GEOM_Object) aBox = my3DPrimOperations->MakeBoxDXDYDZ(2*theL1, 2*aR1Ext, aR1Ext+theL2); + aBox->GetLastFunction()->SetDescription(""); + myTransformOperations->TranslateDXDYDZ(aBox, -theL1, -aR1Ext, -aR1Ext); + aBox->GetLastFunction()->SetDescription(""); + // Apply transformation to box + BRepBuilderAPI_Transform aTransformationBox(aBox->GetValue(), aTrsf, Standard_False); + TopoDS_Shape aBoxShapeTrsf = aTransformationBox.Shape(); + aBox->GetLastFunction()->SetValue(aBoxShapeTrsf); + + // Get the shell of the box + Handle(GEOM_Object) aShell = Handle(GEOM_Object)::DownCast + (myShapesOperations->MakeExplode(aBox, TopAbs_SHELL, true)->Value(1)); + aBox->GetLastFunction()->SetDescription(""); + aShell->GetLastFunction()->SetDescription(""); + // Get the common shapes between shell and shape + Handle(GEOM_Object) aCommonCompound = myBooleanOperations->MakeBoolean (theShape, aShell, 1); // MakeCommon + if (aCommonCompound.IsNull()) { + SetErrorCode(myBooleanOperations->GetErrorCode()); + return false; + } + aCommonCompound->GetLastFunction()->SetDescription(""); + // Explode the faces of common shapes => 3 faces + Handle(TColStd_HSequenceOfTransient) aCommonFaces = + myShapesOperations->MakeExplode(aCommonCompound, TopAbs_FACE, true); + aCommonCompound->GetLastFunction()->SetDescription(""); + std::list aCompoundOfFacesList; + + for (int i=0 ; i<= aCommonFaces->Length()-4 ; i+=4) { + std::list aFacesList; + for (int j = 1 ; j <= 4 ; j++) { + Handle(GEOM_Object) aFace = Handle(GEOM_Object)::DownCast(aCommonFaces->Value(i+j)); // Junction faces + if (!aFace.IsNull()) { + aFace->GetLastFunction()->SetDescription(""); + aFacesList.push_back(aFace); + } + } + Handle(GEOM_Object) aCompoundOfFaces = myShapesOperations->MakeCompound(aFacesList); + if (!aCompoundOfFaces.IsNull()) { + aCompoundOfFaces->GetLastFunction()->SetDescription(""); + aCompoundOfFacesList.push_back(aCompoundOfFaces); + } + } + + if (aCompoundOfFacesList.size() == 3) { + Handle(GEOM_Object) aPln1 = aCompoundOfFacesList.front(); + aCompoundOfFacesList.pop_front(); + Handle(GEOM_Object) aPln2 = aCompoundOfFacesList.front(); + aCompoundOfFacesList.pop_front(); + Handle(GEOM_Object) aPln3 = aCompoundOfFacesList.front(); + aCompoundOfFacesList.pop_front(); + // == END + // + + + // Uncomment the following lines when GetInPlace bug is solved + // == BEGIN +// Handle(GEOM_Object) aP1 = myBasicOperations->MakePointXYZ(-theL1, 0, 0); +// Handle(GEOM_Object) aP2 = myBasicOperations->MakePointXYZ(-0, 0, theL2); +// Handle(GEOM_Object) aP3 = myBasicOperations->MakePointXYZ(theL1, 0, 0); +// aP1->GetLastFunction()->SetDescription(""); +// aP2->GetLastFunction()->SetDescription(""); +// aP3->GetLastFunction()->SetDescription(""); +// Handle(GEOM_Object) aV1 = myBasicOperations->MakeVectorDXDYDZ(-1, 0, 0); +// Handle(GEOM_Object) aV2 = myBasicOperations->MakeVectorDXDYDZ(0, 0, 1); +// Handle(GEOM_Object) aV3 = myBasicOperations->MakeVectorDXDYDZ(1, 0, 0); +// aV1->GetLastFunction()->SetDescription(""); +// aV2->GetLastFunction()->SetDescription(""); +// aV3->GetLastFunction()->SetDescription(""); +// Handle(GEOM_Object) aPln1 = myBasicOperations->MakePlanePntVec(aP1, aV1, 2*(aR1Ext+theL2)); +// Handle(GEOM_Object) aPln2 = myBasicOperations->MakePlanePntVec(aP2, aV2, 2*(aR2Ext)); +// Handle(GEOM_Object) aPln3 = myBasicOperations->MakePlanePntVec(aP3, aV3, 2*(aR1Ext+theL2)); +// aPln1->GetLastFunction()->SetDescription(""); +// aPln2->GetLastFunction()->SetDescription(""); +// aPln3->GetLastFunction()->SetDescription(""); +// +// BRepBuilderAPI_Transform aTransformation1(aPln1->GetValue(), aTrsf, Standard_False); +// TopoDS_Shape aTrsf_Shape1 = aTransformation1.Shape(); +// aPln1->GetLastFunction()->SetValue(aTrsf_Shape1); +// BRepBuilderAPI_Transform aTransformation2(aPln2->GetValue(), aTrsf, Standard_False); +// TopoDS_Shape aTrsf_Shape2 = aTransformation2.Shape(); +// aPln2->GetLastFunction()->SetValue(aTrsf_Shape2); +// BRepBuilderAPI_Transform aTransformation3(aPln3->GetValue(), aTrsf, Standard_False); +// TopoDS_Shape aTrsf_Shape3 = aTransformation3.Shape(); +// aPln3->GetLastFunction()->SetValue(aTrsf_Shape3); + // == END + // + + Handle(GEOM_Object) junctionFaces1 = myShapesOperations->GetInPlace(theShape, aPln1); + if (junctionFaces1.IsNull()) + junctionFaces1 = myShapesOperations->GetShapesOnShapeAsCompound + (aPln1, theShape, TopAbs_FACE, GEOMAlgo_ST_ONIN); + if (!junctionFaces1.IsNull()) { + junctionFaces1->GetLastFunction()->SetDescription(""); + junctionFaces1->SetName("JUNCTION_FACE_1"); + theSeq->Append(junctionFaces1); + } + else { + SetErrorCode("Junction face 1 not found"); + // theSeq->Append(aPln1); + // return false; + } + Handle(GEOM_Object) junctionFaces2 = myShapesOperations->GetInPlace(theShape, aPln2); + if (junctionFaces2.IsNull()) + junctionFaces2 = myShapesOperations->GetShapesOnShapeAsCompound + (aPln2, theShape, TopAbs_FACE, GEOMAlgo_ST_ONIN); + if (!junctionFaces2.IsNull()) { + junctionFaces2->GetLastFunction()->SetDescription(""); + junctionFaces2->SetName("JUNCTION_FACE_2"); + theSeq->Append(junctionFaces2); + } + else { + SetErrorCode("Junction face 2 not found"); + // theSeq->Append(aPln2); + // return false; + } + Handle(GEOM_Object) junctionFaces3 = myShapesOperations->GetInPlace(theShape, aPln3); + if (junctionFaces3.IsNull()) + junctionFaces3 = myShapesOperations->GetShapesOnShapeAsCompound + (aPln3, theShape, TopAbs_FACE, GEOMAlgo_ST_ONIN); + if (!junctionFaces3.IsNull()) { + junctionFaces3->GetLastFunction()->SetDescription(""); + junctionFaces3->SetName("JUNCTION_FACE_3"); + theSeq->Append(junctionFaces3); + } + else { + SetErrorCode("Junction face 3 not found"); + // theSeq->Append(aPln3); + // return false; + } + // Comment the following lines when GetInPlace bug is solved + // == BEGIN + } + // == END + + ///////////////////////// + //// Groups of Edges //// + ///////////////////////// + // Result of propagate + + Handle(GEOM_Function) aFunction = theShape->GetLastFunction(); + + TCollection_AsciiString theDesc = aFunction->GetDescription(); + Handle(TColStd_HSequenceOfTransient) aSeqPropagate = myBlocksOperations->Propagate(theShape); + if (aSeqPropagate.IsNull() || aSeqPropagate->Length() == 0) { + SetErrorCode("Propagation groups not found"); + return false; + } + Standard_Integer aNbGroups = aSeqPropagate->Length(); + // Recover previous description to get rid of Propagate dump + aFunction->SetDescription(theDesc); + +#ifdef FIND_GROUPS_BY_POINTS + // BEGIN: new groups search + + // W2 R2 + // .----.-----.----. + // e| | | | | + // | | | | | + // . | | | . + // g / ''..| | |..'' \ + // f / ''''''' \ + // .---.--'.. | | | ..'--.---. + // |a \ '''...........''' / | + // |-------\------' | '------/-------. + // | \ | / | + // c| \ | / | + // | R1 \ | / | + // | \ | / | + // ._________________|_________________. + // | L1 | | + // | | | + // | | | + // b| | | + // | | | + // |-----------------|-----------------| + // | W1 | | + // '-----------------'-----------------' + // d + + // "Thickness" group (a) + gp_Pnt aPntA (-theL1, 0, theR1 + theW1/2.); + aPntA.Transform(aTrsf); + BRepBuilderAPI_MakeVertex mkVertexA (aPntA); + TopoDS_Vertex aVertA = TopoDS::Vertex(mkVertexA.Shape()); + TopoDS_Shape anEdgeA = GEOMUtils::GetEdgeNearPoint(aShape, aVertA); + + // "Circular quarter of pipe" group (b) + gp_Pnt aPntB (-theL1, -aR1Ext * sin(M_PI/4.), -aR1Ext * sin(M_PI/4.)); + aPntB.Transform(aTrsf); + BRepBuilderAPI_MakeVertex mkVertexB (aPntB); + TopoDS_Vertex aVertB = TopoDS::Vertex(mkVertexB.Shape()); + TopoDS_Shape anEdgeB = GEOMUtils::GetEdgeNearPoint(aShape, aVertB); + + // "Circular quarter of pipe" group (c) + gp_Pnt aPntC (-theL1, -aR1Ext * sin(M_PI/4.), aR1Ext * sin(M_PI/4.)); + aPntC.Transform(aTrsf); + BRepBuilderAPI_MakeVertex mkVertexC (aPntC); + TopoDS_Vertex aVertC = TopoDS::Vertex(mkVertexC.Shape()); + TopoDS_Shape anEdgeC = GEOMUtils::GetEdgeNearPoint(aShape, aVertC); + + // "Main pipe half length" group (d) + gp_Pnt aPntD (-theL1/2., 0, -aR1Ext); + aPntD.Transform(aTrsf); + BRepBuilderAPI_MakeVertex mkVertexD (aPntD); + TopoDS_Vertex aVertD = TopoDS::Vertex(mkVertexD.Shape()); + TopoDS_Shape anEdgeD = GEOMUtils::GetEdgeNearPoint(aShape, aVertD); + + // "Incident pipe half length" group (e) + double aTol10 = Precision::Confusion() * 10.; + gp_Pnt aPntE (-aR2Ext, 0, theL2 - aTol10); + aPntE.Transform(aTrsf); + BRepBuilderAPI_MakeVertex mkVertexE (aPntE); + TopoDS_Vertex aVertE = TopoDS::Vertex(mkVertexE.Shape()); + TopoDS_Shape anEdgeE = GEOMUtils::GetEdgeNearPoint(aShape, aVertE); + + // "Flange" group (f) + double aFx = - aR2Ext - aTol10; + if (shapeType == TSHAPE_CHAMFER) + aFx -= theW; + else if (shapeType == TSHAPE_FILLET) + aFx -= theRF; + gp_Pnt aPntF (aFx, 0, aR1Ext); + aPntF.Transform(aTrsf); + BRepBuilderAPI_MakeVertex mkVertexF (aPntF); + TopoDS_Vertex aVertF = TopoDS::Vertex(mkVertexF.Shape()); + TopoDS_Shape anEdgeF = GEOMUtils::GetEdgeNearPoint(aShape, aVertF); + + // "Chamfer or Fillet" group (g) + TopoDS_Shape anEdgeG; + if (shapeType == TSHAPE_CHAMFER) { + gp_Pnt aPntG (-aR2Ext - theW/2., 0, aR1Ext + theH/2.); + aPntG.Transform(aTrsf); + BRepBuilderAPI_MakeVertex mkVertexG (aPntG); + TopoDS_Vertex aVertG = TopoDS::Vertex(mkVertexG.Shape()); + anEdgeG = GEOMUtils::GetEdgeNearPoint(aShape, aVertG); + } + else if (shapeType == TSHAPE_FILLET) { + gp_Pnt aPntG (-aR2Ext - theRF/2., 0, aR1Ext + theRF/2.); + aPntG.Transform(aTrsf); + BRepBuilderAPI_MakeVertex mkVertexG (aPntG); + TopoDS_Vertex aVertG = TopoDS::Vertex(mkVertexG.Shape()); + anEdgeG = GEOMUtils::GetEdgeNearPoint(aShape, aVertG); + } + + for (int i = 1 ; i <= aNbGroups; i++) { + Handle(GEOM_Object) aGroup = Handle(GEOM_Object)::DownCast(aSeqPropagate->Value(i)); + if (aGroup.IsNull()) + continue; + + TopoDS_Shape aGroupShape = aGroup->GetValue(); + TopTools_IndexedMapOfShape anEdgesMap; + TopExp::MapShapes(aGroupShape, TopAbs_EDGE, anEdgesMap); + + if (anEdgesMap.Contains(anEdgeA)) { // a + aGroup->SetName("THICKNESS"); + theSeq->Append(aGroup); + } + else if (anEdgesMap.Contains(anEdgeB)) { // b + aGroup->SetName("CIRCULAR_QUARTER_PIPE"); + theSeq->Append(aGroup); + } + else if (anEdgesMap.Contains(anEdgeC)) { // c + aGroup->SetName("CIRCULAR_QUARTER_PIPE"); + theSeq->Append(aGroup); + } + else if (anEdgesMap.Contains(anEdgeD)) { // d + aGroup->SetName("HALF_LENGTH_MAIN_PIPE"); + theSeq->Append(aGroup); + } + else if (anEdgesMap.Contains(anEdgeE)) { // e + aGroup->SetName("HALF_LENGTH_INCIDENT_PIPE"); + theSeq->Append(aGroup); + } + else if (anEdgesMap.Contains(anEdgeF)) { // f + aGroup->SetName("FLANGE"); + theSeq->Append(aGroup); + } + else if (shapeType == TSHAPE_CHAMFER) { // g + if (anEdgesMap.Contains(anEdgeG)) { + aGroup->SetName("CHAMFER"); + theSeq->Append(aGroup); + } + } + else if (shapeType == TSHAPE_FILLET) { // g + if (anEdgesMap.Contains(anEdgeG)) { + aGroup->SetName("FILLET"); + theSeq->Append(aGroup); + } + } + else { + } + } + // END: new groups search +#else + bool addGroup; + bool circularFoundAndAdded = false; + bool circularFound10 = false; + bool incidentPipeFound = false; + bool mainPipeFound = false; + bool mainPipeFoundAndAdded = false; + bool radialFound =false; + bool flangeFound = false; + bool flangeFoundAndAdded = false; + bool chamferOrFilletFound = false; + + for (int i = 1 ; i <= aNbGroups; i++) { + addGroup = false; + + Handle(GEOM_Object) aGroup = Handle(GEOM_Object)::DownCast(aSeqPropagate->Value(i)); + if (aGroup.IsNull()) + continue; + + TopoDS_Shape aGroupShape = aGroup->GetValue(); + BRepBuilderAPI_Transform aTransformationShapeInv (aGroupShape, aTrsfInv, Standard_False); + TopoDS_Shape aGroupShapeTrsfInv = aTransformationShapeInv.Shape(); + + TopTools_IndexedMapOfShape anEdgesMap; + TopExp::MapShapes(aGroupShapeTrsfInv,TopAbs_EDGE, anEdgesMap); + Standard_Integer nbEdges = anEdgesMap.Extent(); + + if (shapeType == TSHAPE_BASIC) { + if ((nbEdges >= 21) || /*R1Ext = R2Ext*/(nbEdges == 17)) { // 17, 17+8*{1,2,3}, 21, 21+8*{1,2,3} + addGroup = true; + aGroup->SetName("THICKNESS"); + } + else if (nbEdges == 6) { + if (!circularFoundAndAdded) { + circularFoundAndAdded = true; + addGroup = true; + aGroup->SetName("CIRCULAR_QUARTER_PIPE"); + } + } + else if (nbEdges == 8) { + incidentPipeFound = true; + mainPipeFound = false; + radialFound = false; + flangeFound = false; + + TopExp_Explorer Ex(aGroupShapeTrsfInv,TopAbs_VERTEX); + while (Ex.More()) { + gp_Pnt aP = BRep_Tool::Pnt(TopoDS::Vertex(Ex.Current())); + double x=aP.X(), y=aP.Y(), z=aP.Z(); + + + if ((Abs(x) > aR2Ext + Precision::Confusion()) || + (Abs(y) > aR2Ext + Precision::Confusion())) { + incidentPipeFound = false; + } + + if ( z < -Precision::Confusion()) { + // length of main pipe + mainPipeFound = true; + if (!mainPipeFoundAndAdded) { + mainPipeFoundAndAdded = true; + addGroup = true; + aGroup->SetName("HALF_LENGTH_MAIN_PIPE"); + } + } + + else if (Abs(x) > (theL1-Precision::Confusion())) { + // discretisation circulaire + radialFound = true; + if (!circularFoundAndAdded) { + circularFoundAndAdded = true; + addGroup = true; + aGroup->SetName("CIRCULAR_QUARTER_PIPE"); + } + } + Ex.Next(); + } + if (incidentPipeFound) { + addGroup = true; + aGroup->SetName("HALF_LENGTH_INCIDENT_PIPE"); + } + if (!addGroup && (!incidentPipeFound && + !radialFound && + !mainPipeFound && + !flangeFound)) { + // Flange (collerette) + flangeFound = true; + addGroup = true; + aGroup->SetName("FLANGE"); + } + } + else + continue; + } + else if (shapeType == TSHAPE_CHAMFER || shapeType == TSHAPE_FILLET) { + if (nbEdges >= 25) { // 25, 25+8, 25+16, 25+24 + addGroup = true; + aGroup->SetName("THICKNESS"); + } + else if ((nbEdges == 10) || (nbEdges == 6)) { + if (!circularFoundAndAdded) { + addGroup = true; + circularFoundAndAdded = true; + aGroup->SetName("CIRCULAR_QUARTER_PIPE"); + if (nbEdges == 10) { + circularFound10 = true; + } + } + else if (!circularFound10 && nbEdges == 10) { + circularFound10 = true; + addGroup = true; + aGroup->SetName("CIRCULAR_QUARTER_PIPE"); + } + } + else if (nbEdges == 8) { + incidentPipeFound = true; + mainPipeFound = true; + flangeFound = false; + + bool isNearZ0 = false; + bool isBelowZ0 = false; + + TopExp_Explorer Ex (aGroupShapeTrsfInv,TopAbs_VERTEX); + while (Ex.More()) { + gp_Pnt aP = BRep_Tool::Pnt(TopoDS::Vertex(Ex.Current())); + double x=aP.X(), y=aP.Y(), z=aP.Z(); + + // tuy_princ_long_avant & tuy_princ_long_apres + //bool isMain = (((z < Precision::Confusion()) || (x < Precision::Confusion())) && + // ((y <= aR1Ext + Precision::Confusion()) || + // (y <= -(aR1Ext + Precision::Confusion())) || + // (y <= theR1 + Precision::Confusion()) || + // (y == -(theR1 + Precision::Confusion())))); + bool isMain = ((z < Precision::Confusion() || x < Precision::Confusion()) && + (fabs(y) > theR1 - Precision::Confusion() || + fabs(y) < Precision::Confusion())); + + if (!isMain) { + mainPipeFound = false; + } + + // collerette + //if (z < Precision::Confusion() && !isMain) { + // flangeFound = true; + // if (!flangeFoundAndAdded) { + // flangeFoundAndAdded = true; + // addGroup = true; + // aGroup->SetName("FLANGE"); + // } + //} + if (fabs(z) < Precision::Confusion()) isNearZ0 = true; + if (z < - Precision::Confusion()) isBelowZ0 = true; + + // tuyau incident + if ((Abs(x) > aR2Ext + Precision::Confusion()) || + (Abs(y) > aR2Ext + Precision::Confusion())) { + incidentPipeFound = false; + } + Ex.Next(); + } + if (mainPipeFound) { + addGroup = true; + aGroup->SetName("HALF_LENGTH_MAIN_PIPE"); + } + if (incidentPipeFound) { + addGroup = true; + aGroup->SetName("HALF_LENGTH_INCIDENT_PIPE"); + } + if (isNearZ0 && !isBelowZ0) { + flangeFound = true; + if (!flangeFoundAndAdded) { + flangeFoundAndAdded = true; + addGroup = true; + aGroup->SetName("FLANGE"); + } + } + if (!addGroup && (!incidentPipeFound && + !mainPipeFound && + !flangeFound && + !chamferOrFilletFound)) { + addGroup = true; + chamferOrFilletFound = true; + if (shapeType == TSHAPE_CHAMFER) + aGroup->SetName("CHAMFER"); + else + aGroup->SetName("FILLET"); + } + } + else + continue; + } + // Add group to the list + if (addGroup) + theSeq->Append(aGroup); + } +#endif + + SetErrorCode(OK); + return true; +} + +//============================================================================= +/*! + * Return faces that are laying on surface. + */ +//============================================================================= +bool GEOMImpl_IAdvancedOperations::GetFacesOnSurf + (const TopoDS_Shape &theShape, + const Handle_Geom_Surface& theSurface, + const Standard_Real theTolerance, + TopTools_ListOfShape &theFaces) +{ + GEOMAlgo_FinderShapeOn1 aFinder; + + aFinder.SetShape(theShape); + aFinder.SetTolerance(theTolerance); + aFinder.SetSurface(theSurface); + aFinder.SetShapeType(TopAbs_FACE); + aFinder.SetState(GEOMAlgo_ST_ON); + + // Sets the minimal number of inner points for the faces that do not have own + // inner points at all (for e.g. rectangular planar faces have just 2 triangles). + // Default value=3 + aFinder.SetNbPntsMin(3); + // Sets the maximal number of inner points for edges or faces. + // It is usefull for the cases when this number is very big (e.g =2000) to improve + // the performance. If this value =0, all inner points will be taken into account. + // Default value=0 + aFinder.SetNbPntsMax(100); + aFinder.Perform(); + + // Interprete results + Standard_Integer iErr = aFinder.ErrorStatus(); + // the detailed description of error codes is in GEOMAlgo_FinderShapeOn1.cxx + if (iErr) { + MESSAGE(" iErr : " << iErr); + TCollection_AsciiString aMsg (" iErr : "); + aMsg += TCollection_AsciiString(iErr); + SetErrorCode(aMsg); + return false; + } + Standard_Integer iWrn = aFinder.WarningStatus(); + // the detailed description of warning codes is in GEOMAlgo_FinderShapeOn1.cxx + if (iWrn) { + MESSAGE(" *** iWrn : " << iWrn); + } + + const TopTools_ListOfShape &aListRes = aFinder.Shapes(); // the result + TopTools_ListIteratorOfListOfShape anIter (aListRes); + + for (; anIter.More(); anIter.Next()) { + theFaces.Append(anIter.Value()); + } + + return true; +} + +//============================================================================= +/*! + * Creates and returns conical face. + */ +//============================================================================= +TopoDS_Shape GEOMImpl_IAdvancedOperations::MakeConicalFace + (const gp_Ax2 &theAxis, + const double theRadius, + const double theRadiusThin, + const double theHeight, + const gp_Trsf &theTrsf) +{ + BRepPrimAPI_MakeCone aMkCone (theAxis, theRadius, theRadiusThin, theHeight); + TopoDS_Shape aResult; + + aMkCone.Build(); + if (aMkCone.IsDone()) { + TopExp_Explorer anExp(aMkCone.Shape(), TopAbs_FACE); + + for (; anExp.More(); anExp.Next()) { + TopoDS_Face aFace = TopoDS::Face(anExp.Current()); + + if (aFace.IsNull() == Standard_False) { + BRepAdaptor_Surface anAdaptor(aFace, Standard_False); + + if (anAdaptor.GetType() == GeomAbs_Cone) { + // This is a conical face. Transform and return it. + BRepBuilderAPI_Transform aTransf(aFace, theTrsf, Standard_False); + + aResult = aTransf.Shape(); + break; + } + } + } + } + + return aResult; +} + +//============================================================================= +/*! + * Generate the internal group of a Pipe T-Shape + */ +//============================================================================= +bool GEOMImpl_IAdvancedOperations::MakeInternalGroup + (const Handle(GEOM_Object) &theShape, + const double theR1, const double theLen1, + const double theR2, const double theLen2, + const double theRL, double theTransLenL, + const double theRR, double theTransLenR, + const double theRI, double theTransLenI, + const Handle(TColStd_HSequenceOfTransient) &theSeq, + const gp_Trsf &theTrsf) +{ + SetErrorCode(KO); + + if (theShape.IsNull()) { + return false; + } + + TopoDS_Shape aShape = theShape->GetValue(); + + if (aShape.IsNull()) { + SetErrorCode("Shape is not defined"); + return false; + } + + // Compute tolerance + Standard_Real aMaxTol = -RealLast(); + TopExp_Explorer anExp(aShape, TopAbs_VERTEX); + + for (; anExp.More(); anExp.Next()) { + TopoDS_Vertex aVertex = TopoDS::Vertex(anExp.Current()); + + if (aVertex.IsNull() == Standard_False) { + const Standard_Real aTol = BRep_Tool::Tolerance(aVertex); + + if (aTol > aMaxTol) { + aMaxTol = aTol; + } + } + } + + // Construct internal surfaces. + Standard_Integer i = 0; + const Standard_Integer aMaxNbSurf = 5; + Handle(Geom_Surface) aSurface[aMaxNbSurf]; + TopTools_ListOfShape aConicalFaces; + Standard_Real aTolConf = Precision::Confusion(); + + // 1. Construct the internal surface of main pipe. + gp_Ax2 anAxis1 (gp::Origin(), gp::DX(), gp::DZ()); + gp_Ax2 anAxis2 (gp::Origin(), gp::DZ(), gp::DX()); + + aSurface[i++] = new Geom_CylindricalSurface(anAxis1, theR1); + + // 2. Construct the internal surface of incident pipe. + aSurface[i++] = new Geom_CylindricalSurface(anAxis2, theR2); + + // 3. Construct the internal surface of left reduction pipe. + if (theRL > aTolConf) { + aSurface[i++] = new Geom_CylindricalSurface(anAxis1, theRL); + + if (theTransLenL > aTolConf) { + // 3.1. Construct the internal surface of left transition pipe. + gp_Pnt aPLeft (-theLen1, 0., 0.); + gp_Ax2 anAxisLeft (aPLeft, -gp::DX(), gp::DZ()); + TopoDS_Shape aConeLeft = + MakeConicalFace(anAxisLeft, theR1, theRL, theTransLenL, theTrsf); + + if (aConeLeft.IsNull() == Standard_False) { + aConicalFaces.Append(aConeLeft); + } + } + } + + // 4. Construct the internal surface of right reduction pipe. + if (theRR > aTolConf) { + // There is no need to construct another cylinder of the same radius. Skip it. + if (Abs(theRR - theRL) > aTolConf) { + aSurface[i++] = new Geom_CylindricalSurface(anAxis1, theRR); + } + + if (theTransLenL > aTolConf) { + // 4.1. Construct the internal surface of right transition pipe. + gp_Pnt aPRight (theLen1, 0., 0.); + gp_Ax2 anAxisRight (aPRight, gp::DX(), gp::DZ()); + TopoDS_Shape aConeRight = + MakeConicalFace(anAxisRight, theR1, theRR, theTransLenR, theTrsf); + + if (aConeRight.IsNull() == Standard_False) { + aConicalFaces.Append(aConeRight); + } + } + } + + // 5. Construct the internal surface of incident reduction pipe. + if (theRI > aTolConf) { + aSurface[i++] = new Geom_CylindricalSurface(anAxis2, theRI); + + if (theTransLenI > aTolConf) { + // 5.1. Construct the internal surface of incident transition pipe. + gp_Pnt aPInci (0., 0., theLen2); + gp_Ax2 anAxisInci (aPInci, gp::DZ(), gp::DX()); + TopoDS_Shape aConeInci = + MakeConicalFace(anAxisInci, theR2, theRI, theTransLenI, theTrsf); + + if (aConeInci.IsNull() == Standard_False) { + aConicalFaces.Append(aConeInci); + } + } + } + + // Get faces that are laying on cylindrical surfaces. + TopTools_ListOfShape aFaces; + gp_Trsf anInvTrsf = theTrsf.Inverted(); + + for (i = 0; i < aMaxNbSurf; i++) { + if (aSurface[i].IsNull()) { + break; + } + + aSurface[i]->Transform(theTrsf); + + TopTools_ListOfShape aLocalFaces; + + if (!GetFacesOnSurf(aShape, aSurface[i], aMaxTol, aLocalFaces)) { + return false; + } + + if (i < 2) { + // Check if the result contains outer cylinders. + // It is required for main and incident pipes. + TopTools_ListIteratorOfListOfShape anIter(aLocalFaces); + + while (anIter.More()) { + TopExp_Explorer anExp(anIter.Value(), TopAbs_VERTEX); + Standard_Boolean isInside = Standard_False; + + // Get a vertex from this shape + if (anExp.More()) { + TopoDS_Vertex aVtx = TopoDS::Vertex(anExp.Current()); + + if (aVtx.IsNull() == Standard_False) { + gp_Pnt aPnt = BRep_Tool::Pnt(aVtx); + + aPnt.Transform(anInvTrsf); + + if (i == 0) { + // Check if the point is inside the main pipe. + isInside = (Abs(aPnt.X()) <= theLen1); + } else { // i == 1 + // Check if the point is inside the incident pipe. + isInside = (aPnt.Z() <= theLen2); + } + } + } + + if (isInside) { + // Keep this face. + anIter.Next(); + } else { + // Remove this face. + aLocalFaces.Remove(anIter); + } + } + } + + aFaces.Append(aLocalFaces); + } + + // Get faces that are laying on conical faces. + if (aConicalFaces.IsEmpty() == Standard_False) { + Handle(GEOM_Object) aCone = + GetEngine()->AddObject(GetDocID(), GEOM_TSHAPE); + Handle(GEOM_Function) aFunction = + aCone->AddFunction(GEOMImpl_PipeTShapeDriver::GetID(), TSHAPE_BASIC); + TopTools_ListIteratorOfListOfShape aFIter(aConicalFaces); + Handle(GEOM_Object) aConeFromShape; + + for (; aFIter.More(); aFIter.Next()) { + aFunction->SetValue(aFIter.Value()); + aConeFromShape = myShapesOperations->GetInPlace(theShape, aCone); + + if (aConeFromShape.IsNull() == Standard_False) { + aConeFromShape->GetLastFunction()->SetDescription(""); + TopoDS_Shape aConeFaces = aConeFromShape->GetValue(); + TopExp_Explorer anExp(aConeFaces, TopAbs_FACE); + + for (; anExp.More(); anExp.Next()) { + TopoDS_Face aConeFace = TopoDS::Face(anExp.Current()); + + if (aConeFace.IsNull() == Standard_False) { + aFaces.Append(aConeFace); + } + } + } + } + } + + // Create a group of internal faces. + if (aFaces.IsEmpty() == Standard_False) { + Handle(GEOM_Object) aGroup = myGroupOperations->CreateGroup(theShape, TopAbs_FACE); + + if (aGroup.IsNull() == Standard_False) { + aGroup->GetLastFunction()->SetDescription(""); + aGroup->SetName("INTERNAL_FACES"); + + TopTools_IndexedMapOfShape anIndices; + Handle(TColStd_HSequenceOfInteger) aSeqIDs = new TColStd_HSequenceOfInteger; + + TopExp::MapShapes(aShape, anIndices); + + TopTools_ListIteratorOfListOfShape anIter(aFaces); + + for (; anIter.More(); anIter.Next()) { + const TopoDS_Shape &aFace = anIter.Value(); + const Standard_Integer anIndex = anIndices.FindIndex(aFace); + + if (anIndex > 0) { + aSeqIDs->Append(anIndex); + } + } + + myGroupOperations->UnionIDs(aGroup, aSeqIDs); + aGroup->GetLastFunction()->SetDescription(""); + theSeq->Append(aGroup); + } + } + + SetErrorCode(OK); + + return true; +} + +bool GEOMImpl_IAdvancedOperations::MakePipeTShapePartition(Handle(GEOM_Object) theShape, + double theR1, double theW1, double theL1, + double theR2, double theW2, double theL2, + double theH, double theW, + double theRF, bool isNormal) +{ + SetErrorCode(KO); + + // Build tools for partition operation: + // 1 face and 2 planes + // Face + Handle(GEOM_Object) arete_intersect_int; + Handle(GEOM_Object) wire_t, wire_t2, face_t, face_t2; + Handle(GEOM_Object) chan_racc; + Handle(GEOM_Object) vi1, vi2; + Handle(GEOM_Object) Te3; + + try { +#if OCC_VERSION_LARGE > 0x06010000 + OCC_CATCH_SIGNALS; +#endif + Handle(GEOM_Object) Vector_Z = myBasicOperations->MakeVectorDXDYDZ(0, 0, 1); + Vector_Z->GetLastFunction()->SetDescription(""); + + // Useful values + double aSize = 2*(theL1 + theL2); + double aR1Ext = theR1 + theW1; + double aR2Ext = theR2 + theW2; + double theVertCylinderRadius = aR2Ext + theW + theRF; + double theHoriCylinderRadius = aR1Ext + theH + theRF; + + // Common edges on internal cylinder + Handle(GEOM_Object) box_i = my3DPrimOperations->MakeBoxDXDYDZ(theR2, theR2, theR1); + box_i->GetLastFunction()->SetDescription(""); + box_i = myTransformOperations->TranslateDXDYDZ(box_i, -theR2, -theR2, 0); + box_i->GetLastFunction()->SetDescription(""); + + Handle(GEOM_Function) aFunction = theShape->GetLastFunction(); + TCollection_AsciiString theDesc = aFunction->GetDescription(); + Handle(TColStd_HSequenceOfTransient) edges_i = + myShapesOperations->GetShapesOnBox(box_i, theShape, TopAbs_EDGE, GEOMAlgo_ST_IN); + // Recover previous description to get rid of Propagate dump + aFunction->SetDescription(theDesc); + if (edges_i.IsNull() || edges_i->Length() == 0) { + SetErrorCode("Internal edges not found"); + return false; + } + for (int i=1; i<=edges_i->Length();i++) { + Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(edges_i->Value(i)); + anObj->GetLastFunction()->SetDescription(""); + } + arete_intersect_int = Handle(GEOM_Object)::DownCast(edges_i->Value(1)); + + // search for vertices located on both internal pipes + aFunction = theShape->GetLastFunction(); + theDesc = aFunction->GetDescription(); + Handle(TColStd_HSequenceOfTransient) vertices_i = + myShapesOperations->GetShapesOnBox(box_i, theShape, TopAbs_VERTEX, GEOMAlgo_ST_ONIN); + // Recover previous description to get rid of Propagate dump + aFunction->SetDescription(theDesc); + if (vertices_i.IsNull() || vertices_i->Length() == 0) { + SetErrorCode("Internal vertices not found"); + return false; + } + + for (int i = 1; i <= vertices_i->Length(); i++) { + Handle(GEOM_Object) v = Handle(GEOM_Object)::DownCast(vertices_i->Value(i)); + v->GetLastFunction()->SetDescription(""); + TopoDS_Vertex aVertex = TopoDS::Vertex(v->GetValue()); + gp_Pnt aP = BRep_Tool::Pnt(aVertex); +// std::cout << "Coords: " << aP.X() << ", " << aP.Y() << ", " << aP.Z() << std::endl; + if (Abs(aP.X()) <= Precision::Confusion()) { + if (Abs(aP.Y()) - theR1 <= Precision::Confusion()) { + vi1 = v; + } + } else if (Abs(aP.Y()) <= Precision::Confusion()) { + if (Abs(aP.X()) - theR1 <= Precision::Confusion()) { + vi2 = v; + } + } + } + + std::list theShapes; + + if (isNormal) { + Handle(GEOM_Object) ve1, ve2; + + Handle(GEOM_Object) box_e = my3DPrimOperations->MakeBoxDXDYDZ(aR2Ext, aR2Ext, aR1Ext); + box_e->GetLastFunction()->SetDescription(""); + box_e = myTransformOperations->TranslateDXDYDZ(box_e, -aR2Ext, -aR2Ext, 0); + box_e->GetLastFunction()->SetDescription(""); + // Common edges on external cylinder + aFunction = theShape->GetLastFunction(); + theDesc = aFunction->GetDescription(); + Handle(TColStd_HSequenceOfTransient) edges_e = + myShapesOperations->GetShapesOnBox(box_e, theShape, TopAbs_EDGE, GEOMAlgo_ST_IN); + // Recover previous description to get rid of Propagate dump + aFunction->SetDescription(theDesc); + if (edges_e.IsNull() || edges_e->Length() == 0) { + SetErrorCode("External edges not found"); + return false; + } + for (int i=1; i<=edges_e->Length();i++) { + Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(edges_e->Value(i)); + anObj->GetLastFunction()->SetDescription(""); + } + + // search for vertices located on both external pipes + aFunction = theShape->GetLastFunction(); + theDesc = aFunction->GetDescription(); + Handle(TColStd_HSequenceOfTransient) vertices_e = + myShapesOperations->GetShapesOnBox(box_e, theShape, TopAbs_VERTEX, GEOMAlgo_ST_ONIN); + // Recover previous description to get rid of Propagate dump + aFunction->SetDescription(theDesc); + if (vertices_e.IsNull() || vertices_e->Length() == 0) { + SetErrorCode("External vertices not found"); + return false; + } + + for (int i = 1; i <= vertices_e->Length(); i++) { + Handle(GEOM_Object) v = Handle(GEOM_Object)::DownCast(vertices_e->Value(i)); + v->GetLastFunction()->SetDescription(""); + TopoDS_Vertex aVertex = TopoDS::Vertex(v->GetValue()); + gp_Pnt aP = BRep_Tool::Pnt(aVertex); +// std::cout << "Coords: " << aP.X() << ", " << aP.Y() << ", " << aP.Z() << std::endl; + if (Abs(aP.X()) <= Precision::Confusion()) { + if (Abs(aP.Y()) - theR2 > Precision::Confusion()) { + ve1 = v; + } + } else if (Abs(aP.Y()) <= Precision::Confusion()) { + if (Abs(aP.X()) - theR2 > Precision::Confusion()) { + ve2 = v; + } + } + if ( !ve1.IsNull() && !ve2.IsNull()) + break; + } + Handle(GEOM_Object) edge_e1, edge_e2; + + edge_e1 = myBasicOperations->MakeLineTwoPnt(ve1, vi1); + if (edge_e1.IsNull()) { + SetErrorCode("Edge 1 could not be built"); + return false; + } + + edge_e2 = myBasicOperations->MakeLineTwoPnt(ve2, vi2); + if (edge_e2.IsNull()) { + SetErrorCode("Edge 2 could not be built"); + return false; + } + + edge_e1->GetLastFunction()->SetDescription(""); + edge_e2->GetLastFunction()->SetDescription(""); + + std::list edge_e_elist; + edge_e_elist.push_back(arete_intersect_int); + edge_e_elist.push_back(edge_e1); + edge_e_elist.push_back(Handle(GEOM_Object)::DownCast(edges_e->Value(1))); + edge_e_elist.push_back(edge_e2); + wire_t = myShapesOperations->MakeWire(edge_e_elist, 1e-7); + if (wire_t.IsNull()) { + SetErrorCode("Impossible to build wire"); + return false; + } + wire_t->GetLastFunction()->SetDescription(""); + face_t = myShapesOperations->MakeFace(wire_t, false); + if (face_t.IsNull()) { + SetErrorCode("Impossible to build face"); + return false; + } + face_t->GetLastFunction()->SetDescription(""); + + theShapes.push_back(theShape); + theShapes.push_back(vi1); + theShapes.push_back(vi2); + theShapes.push_back(ve1); + theShapes.push_back(ve2); + theShapes.push_back(edge_e1); + theShapes.push_back(edge_e2); + theShapes.push_back(wire_t); + theShapes.push_back(face_t); + } + else { + Handle(GEOM_Object) P1, P2, P3, P4, P5, P6; + int idP1, idP2, idP3, idP4; + int PZX, PZY; + double ZX=0, ZY=0; + std::vector LX; + std::vector LY; + Handle(GEOM_Object) box_e = my3DPrimOperations->MakeBoxDXDYDZ + (theVertCylinderRadius, theVertCylinderRadius, theHoriCylinderRadius); + box_e->GetLastFunction()->SetDescription(""); + box_e = myTransformOperations->TranslateDXDYDZ + (box_e, -theVertCylinderRadius, -theVertCylinderRadius, 0); + box_e->GetLastFunction()->SetDescription(""); + + aFunction = theShape->GetLastFunction(); + theDesc = aFunction->GetDescription(); + Handle(TColStd_HSequenceOfTransient) extremVertices = + myShapesOperations->GetShapesOnBox(box_e, theShape, TopAbs_VERTEX, GEOMAlgo_ST_ONIN); + // Recover previous description to get rid of Propagate dump + aFunction->SetDescription(theDesc); + + if (extremVertices.IsNull() || extremVertices->Length() == 0) { + if (theRF == 0) + SetErrorCode("Vertices on chamfer not found"); + else + SetErrorCode("Vertices on fillet not found"); + return false; + } + + theShapes.push_back(theShape); + theShapes.push_back(box_e); + if (extremVertices->Length() != 6) { + // for (int i=1; i<=extremVertices->Length(); i++){ + // theShapes.push_back(Handle(GEOM_Object)::DownCast(extremVertices->Value(i))); + // } + // Handle(GEOM_Object) aCompound = myShapesOperations->MakeCompound(theShapes); + // TopoDS_Shape aCompoundShape = aCompound->GetValue(); + // theShape->GetLastFunction()->SetValue(aCompoundShape); + SetErrorCode("Bad number of vertices on chamfer found"); + return false; + } + + for (int i=1; i<=extremVertices->Length(); i++){ + Handle(GEOM_Object) aV = Handle(GEOM_Object)::DownCast(extremVertices->Value(i)); + aV->GetLastFunction()->SetDescription(""); + gp_Pnt aP = BRep_Tool::Pnt(TopoDS::Vertex(aV->GetValue())); + + if (Abs(aP.X()) <= Precision::Confusion()) { + if (Abs(aP.Y()) - theR2 > Precision::Confusion()) { + LX.push_back(i); + if (aP.Z()-ZX > Precision::Confusion()) { + ZX = aP.Z(); + PZX = i; + } + } + } + else { + if (Abs(aP.X()) - theR2 > Precision::Confusion()) { + LY.push_back(i); + if (aP.Z() - ZY > Precision::Confusion()) { + ZY = aP.Z(); + PZY = i; + } + } + } + } + + idP2 = PZX; + idP4 = PZY; + idP1 = LX.at(0); + if (LX.at(0) == PZX) + idP1 = LX.at(1); + idP3 = LY.at(0); + if (LY.at(0) == PZY) + idP3 = LY.at(1); + + P1 = Handle(GEOM_Object)::DownCast(extremVertices->Value(idP1)); + P2 = Handle(GEOM_Object)::DownCast(extremVertices->Value(idP2)); + P3 = Handle(GEOM_Object)::DownCast(extremVertices->Value(idP3)); + P4 = Handle(GEOM_Object)::DownCast(extremVertices->Value(idP4)); + + Handle(GEOM_Object) Cote_1 = myBasicOperations->MakeLineTwoPnt(P1, vi1); + if (Cote_1.IsNull()) { + SetErrorCode("Impossible to build edge in thickness"); + return false; + } + Cote_1->GetLastFunction()->SetDescription(""); + + Handle(GEOM_Object) Cote_2 = myBasicOperations->MakeLineTwoPnt(vi2, P3); + if (Cote_2.IsNull()) { + SetErrorCode("Impossible to build edge in thickness"); + return false; + } + Cote_2->GetLastFunction()->SetDescription(""); + + // edge_chan_princ = arete du chanfrein (ou raccord) sur le tuyau principal + // edge_chan_inc = arete du chanfrein (ou raccord) sur le tuyau incident + // std::cerr << "Getting chamfer edge on main pipe" << std::endl; + Handle(GEOM_Object) edge_chan_princ = myBlocksOperations->GetEdge(theShape, P1, P3); + if (edge_chan_princ.IsNull()) { + SetErrorCode("Impossible to find edge on main pipe"); + return false; + } + edge_chan_princ->GetLastFunction()->SetDescription(""); + + Handle(GEOM_Object) edge_chan_inc = myBlocksOperations->GetEdge(theShape, P2, P4); + if (edge_chan_inc.IsNull()) { + SetErrorCode("Impossible to find edge on incident pipe"); + return false; + } + edge_chan_inc->GetLastFunction()->SetDescription(""); + + std::list edgeList1; + edgeList1.push_back(edge_chan_princ); + edgeList1.push_back(Cote_1); + edgeList1.push_back(arete_intersect_int); + edgeList1.push_back(Cote_2); + + // std::cerr << "Creating wire 1" << std::endl; + wire_t = myShapesOperations->MakeWire(edgeList1, 1e-7); + if (wire_t.IsNull()) { + SetErrorCode("Impossible to build wire"); + return false; + } + wire_t->GetLastFunction()->SetDescription(""); + + // std::cerr << "Creating face 1" << std::endl; + face_t = myShapesOperations->MakeFace(wire_t, false); + if (face_t.IsNull()) { + SetErrorCode("Impossible to build face"); + return false; + } + face_t->GetLastFunction()->SetDescription(""); + theShapes.push_back(face_t); + + gp_Pnt aP2 = BRep_Tool::Pnt(TopoDS::Vertex(P2->GetValue())); + gp_Pnt aP5 = BRep_Tool::Pnt(TopoDS::Vertex(vi1->GetValue())); + double deltaZ = aP2.Z() - aP5.Z(); + // std::cerr << "Creating new point from vi1 with deltaZ = " << deltaZ << std::endl; + Handle(GEOM_Object) P5bis = myTransformOperations->TranslateDXDYDZCopy(vi1, 0, 0, deltaZ); + if (P5bis.IsNull()) { + SetErrorCode("Impossible to translate vertex"); + return false; + } + P5bis->GetLastFunction()->SetDescription(""); + + gp_Pnt aP4 = BRep_Tool::Pnt(TopoDS::Vertex(P4->GetValue())); + gp_Pnt aP6 = BRep_Tool::Pnt(TopoDS::Vertex(vi2->GetValue())); + deltaZ = aP4.Z() - aP6.Z(); + // std::cerr << "Creating new point from vi2 with deltaZ = " << deltaZ << std::endl; + Handle(GEOM_Object) P6bis = myTransformOperations->TranslateDXDYDZCopy(vi2, 0, 0, deltaZ); + if (P6bis.IsNull()) { + SetErrorCode("Impossible to translate vertex"); + return false; + } + P6bis->GetLastFunction()->SetDescription(""); + + // std::cerr << "Creating new line 1 from 2 previous points" << std::endl; + Handle(GEOM_Object) Cote_3 = myBasicOperations->MakeLineTwoPnt(P5bis, P2); + if (Cote_3.IsNull()) { + SetErrorCode("Impossible to build edge in thickness"); + return false; + } + Cote_3->GetLastFunction()->SetDescription(""); + + // std::cerr << "Creating new line 2 from 2 previous points" << std::endl; + Handle(GEOM_Object) Cote_4 = myBasicOperations->MakeLineTwoPnt(P6bis, P4); + if (Cote_4.IsNull()) { + SetErrorCode("Impossible to build edge in thickness"); + return false; + } + Cote_4->GetLastFunction()->SetDescription(""); + + // std::cerr << "Creating new line 3 from 2 previous points" << std::endl; + Handle(GEOM_Object) Cote_5 = myBasicOperations->MakeLineTwoPnt(P5bis, P6bis); + if (Cote_4.IsNull()) { + SetErrorCode("Impossible to build edge in thickness"); + return false; + } + Cote_5->GetLastFunction()->SetDescription(""); + + //std::list edgeList2; + //edgeList2.push_back(edge_chan_inc); + //edgeList2.push_back(Cote_3); + //edgeList2.push_back(Cote_5); + //edgeList2.push_back(Cote_4); + // std::cerr << "Creating wire 2" << std::endl; + //wire_t2 = myShapesOperations->MakeWire(edgeList2, 1e-7); + //if (wire_t2.IsNull()) { + // SetErrorCode("Impossible to build wire"); + // return false; + //} + //wire_t2->GetLastFunction()->SetDescription(""); + // std::cerr << "Creating face 2" << std::endl; + //face_t2 = myShapesOperations->MakeFace(wire_t2, false); + + // Mantis issue 0021682 + face_t2 = my3DPrimOperations->MakePrismVecH(edge_chan_inc, Cote_4, - (theR2 + theW2)); + //face_t2 = my3DPrimOperations->MakePrismVecH(edge_chan_inc, Cote_4, - 2.0*theR2); + if (face_t2.IsNull()) { + SetErrorCode("Impossible to build face"); + return false; + } + face_t2->GetLastFunction()->SetDescription(""); + theShapes.push_back(face_t2); + } + + // Planes + Handle(GEOM_Object) aP0 = myBasicOperations->MakePointXYZ(0, 0, 0); + Handle(GEOM_Object) aVZ = myBasicOperations->MakeVectorDXDYDZ(0, 0, 1); + Handle(GEOM_Object) aVXZ = myBasicOperations->MakeVectorDXDYDZ(aR1Ext, 0, 0.5*(theL1+theVertCylinderRadius)); + Handle(GEOM_Object) aPlnOZ = myBasicOperations->MakePlanePntVec(aP0, aVZ, aSize); + Handle(GEOM_Object) aPlnOXZ = myBasicOperations->MakePlanePntVec(aP0, aVXZ, aSize); + aP0->GetLastFunction()->SetDescription(""); + aVZ->GetLastFunction()->SetDescription(""); + aVXZ->GetLastFunction()->SetDescription(""); + aPlnOZ->GetLastFunction()->SetDescription(""); + aPlnOXZ->GetLastFunction()->SetDescription(""); + theShapes.push_back(aPlnOZ); + theShapes.push_back(aPlnOXZ); + + // Partition + Handle(TColStd_HSequenceOfTransient) partitionShapes = new TColStd_HSequenceOfTransient; + Handle(TColStd_HSequenceOfTransient) theTools = new TColStd_HSequenceOfTransient; + Handle(TColStd_HSequenceOfTransient) theKeepInside = new TColStd_HSequenceOfTransient; + Handle(TColStd_HSequenceOfTransient) theRemoveInside = new TColStd_HSequenceOfTransient; + Handle(TColStd_HArray1OfInteger) theMaterials; + + partitionShapes->Append(theShape); + theTools->Append(aPlnOZ); + if (Abs(aR1Ext - aR2Ext) > Precision::Confusion()) + theTools->Append(aPlnOXZ); + theTools->Append(face_t); + if (!isNormal) + theTools->Append(face_t2); + + Te3 = myBooleanOperations->MakePartition + (partitionShapes, theTools, theKeepInside, theRemoveInside, + TopAbs_SOLID, false, theMaterials, 0, false); + if (Te3.IsNull()) { + SetErrorCode("Impossible to build partition of TShape"); + return false; + } + Te3->GetLastFunction()->SetDescription(""); + + // Last verification: result should be a block + std::list errList; + if (!myBlocksOperations->CheckCompoundOfBlocks(Te3,errList)) { + SetErrorCode("TShape is not a compound of block"); + return false; + } + +// // BEGIN Compound of created shapes - Only for debug purpose +// theShapes.clear(); +// theShapes.push_back(theShape); +// theShapes.push_back(aPlnOZ); +// if (Abs(aR1Ext - aR2Ext) > Precision::Confusion() ) +// theShapes.push_back(aPlnOXZ); +// theShapes.push_back(face_t); +// if (!isNormal) +// theShapes.push_back(face_t2); +// +// Handle(GEOM_Object) aCompound = myShapesOperations->MakeCompound(theShapes); +// TopoDS_Shape aCompoundShape = aCompound->GetValue(); +// theShape->GetLastFunction()->SetValue(aCompoundShape); +// // END Compound of created shapes - Only for debug purpose + + TopoDS_Shape aShape = Te3->GetValue(); + theShape->GetLastFunction()->SetValue(aShape); + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return false; + } + + SetErrorCode(OK); + return true; +} + +// Mirror and glue faces +bool GEOMImpl_IAdvancedOperations::MakePipeTShapeMirrorAndGlue(Handle(GEOM_Object) theShape, + double theR1, double theW1, double theL1, + double theR2, double theW2, double theL2) +{ + SetErrorCode(KO); + + // Useful values + double aSize = 2*(theL1 + theL2); + double aR1Ext = theR1 + theW1; + + // Planes + Handle(GEOM_Object) aP0 = myBasicOperations->MakePointXYZ(0, 0, 0); + aP0->GetLastFunction()->SetDescription(""); + Handle(GEOM_Object) aVX = myBasicOperations->MakeVectorDXDYDZ(1, 0, 0); + Handle(GEOM_Object) aVY = myBasicOperations->MakeVectorDXDYDZ(0, 1, 0); + aVX->GetLastFunction()->SetDescription(""); + aVY->GetLastFunction()->SetDescription(""); + Handle(GEOM_Object) aPlane_OX = myBasicOperations->MakePlanePntVec(aP0, aVX, 2*(aR1Ext + theL2)); + Handle(GEOM_Object) aPlane_OY = myBasicOperations->MakePlanePntVec(aP0, aVY, aSize); + aPlane_OX->GetLastFunction()->SetDescription(""); + aPlane_OY->GetLastFunction()->SetDescription(""); + + Handle(GEOM_Object) Te4 = myTransformOperations->MirrorPlaneCopy(theShape, aPlane_OX); + if (Te4.IsNull()) { + SetErrorCode("Impossible to build mirror of quarter TShape"); + return false; + } + + Handle(GEOM_Object) Te5 = myTransformOperations->MirrorPlaneCopy(theShape, aPlane_OY); + if (Te5.IsNull()) { + SetErrorCode("Impossible to build mirror of half TShape"); + return false; + } + + Handle(GEOM_Object) Te6 = myTransformOperations->MirrorPlaneCopy(Te4, aPlane_OY); + if (Te6.IsNull()) { + SetErrorCode("Impossible to build mirror of half TShape"); + return false; + } + + std::list aShapesList; + aShapesList.push_back(theShape); + aShapesList.push_back(Te4); + aShapesList.push_back(Te5); + aShapesList.push_back(Te6); + Handle(GEOM_Object) Te7 = myShapesOperations->MakeCompound(aShapesList); + if (Te7.IsNull()) { + SetErrorCode("Impossible to build compound"); + return false; + } + + // Copy source shape + TopoDS_Shape aShapeCopy; + TColStd_IndexedDataMapOfTransientTransient aMapTShapes; + TNaming_CopyShape::CopyTool(Te7->GetValue(), aMapTShapes, aShapeCopy); + + Handle(GEOM_Object) Te8 = myShapesOperations->MakeGlueFaces(Te7, 1e-7, true); + if (Te8.IsNull()) { + SetErrorCode("Impossible to glue faces of TShape"); + return false; + } + + TopoDS_Shape aShape = Te8->GetValue(); + BRepCheck_Analyzer anAna (aShape, Standard_True); + + if (!anAna.IsValid()) { + // Try to do gluing with the tolerance equal to maximal + // tolerance of vertices of the source shape. + Standard_Real aTolMax = -RealLast(); + + for (TopExp_Explorer ExV (aShapeCopy, TopAbs_VERTEX); ExV.More(); ExV.Next()) { + TopoDS_Vertex aVertex = TopoDS::Vertex(ExV.Current()); + Standard_Real aTol = BRep_Tool::Tolerance(aVertex); + + if (aTol > aTolMax) { + aTolMax = aTol; + } + } + + // Perform gluing + Te7->GetLastFunction()->SetValue(aShapeCopy); + Te8 = myShapesOperations->MakeGlueFaces(Te7, aTolMax, true); + + if (Te8.IsNull()) { + SetErrorCode("Impossible to glue faces of TShape"); + return false; + } + + aShape = Te8->GetValue(); + } + + + theShape->GetLastFunction()->SetValue(aShape); + + Te4->GetLastFunction()->SetDescription(""); + Te5->GetLastFunction()->SetDescription(""); + Te6->GetLastFunction()->SetDescription(""); + Te7->GetLastFunction()->SetDescription(""); + Te8->GetLastFunction()->SetDescription(""); + + SetErrorCode(OK); + return true; +} + +//======================================================================= +//function : MakePipeTShapeThicknessReduction +//purpose : Static method. Add thiskness reduction elements at the three +// open ends of the T-Shape. +//======================================================================= +TopoDS_Shape GEOMImpl_IAdvancedOperations::MakePipeTShapeThicknessReduction + (TopoDS_Shape theShape, + double r1, double w1, double l1, + double r2, double w2, double l2, + double rL, double wL, double ltransL, double lthinL, + double rR, double wR, double ltransR, double lthinR, + double rI, double wI, double ltransI, double lthinI, + bool fuseReductions) +{ + // Add thickness reduction elements + // at the three extremities: Left, Right and Incident + // + // ---------------------. + // W \ + // ---------------------. \ + // ^ \ '-----------------. + // |R \ Wthin | + // | '-----------------' + // v Rthin + // --.--.--.--.--.--.--.--.--.--.--.--.--.--.-- + // Ltrans Lthin + + TopoDS_Shape aResult = theShape; + double aTol = Precision::Confusion(); + + gp_Vec aVX = gp::DX(), aVZ = gp::DZ(); + + // Left reduction (rL, wL, ltransL, lthinL) + if (rL > aTol && wL > aTol && ltransL > aTol) { + gp_Pnt aPLeft (-l1, 0, 0); + gp_Ax2 anAxesLeft (aPLeft, -aVX, aVZ); + TopoDS_Shape aReductionLeft = GEOMImpl_IAdvancedOperations::MakeThicknessReduction + (anAxesLeft, r1, w1, rL, wL, ltransL, lthinL, fuseReductions); + + if (fuseReductions) { + BRepAlgoAPI_Fuse fuseL (aResult, aReductionLeft); + if (!fuseL.IsDone()) + StdFail_NotDone::Raise("Cannot fuse Te with left reduction"); + aResult = fuseL.Shape(); + } + else { + BRep_Builder B; + TopoDS_Compound C; + B.MakeCompound(C); + B.Add(C, aResult); + B.Add(C, aReductionLeft); + aResult = C; + } + } + + // Right reduction + if (rR > aTol && wR > aTol && ltransR > aTol) { + gp_Pnt aPRight (l1, 0, 0); + gp_Ax2 anAxesRight (aPRight, aVX, aVZ); + TopoDS_Shape aReductionRight = GEOMImpl_IAdvancedOperations::MakeThicknessReduction + (anAxesRight, r1, w1, rR, wR, ltransR, lthinR, fuseReductions); + + if (fuseReductions) { + BRepAlgoAPI_Fuse fuseR (aResult, aReductionRight); + if (!fuseR.IsDone()) + StdFail_NotDone::Raise("Cannot fuse Te with right reduction"); + aResult = fuseR.Shape(); + } + else { + BRep_Builder B; + TopoDS_Compound C; + B.MakeCompound(C); + B.Add(C, aResult); + B.Add(C, aReductionRight); + aResult = C; + } + } + + // Incident reduction + if (rI > aTol && wI > aTol && ltransI > aTol) { + gp_Pnt aPInci (0, 0, l2); + gp_Ax2 anAxesInci (aPInci, aVZ, aVX); + TopoDS_Shape aReductionInci = GEOMImpl_IAdvancedOperations::MakeThicknessReduction + (anAxesInci, r2, w2, rI, wI, ltransI, lthinI, fuseReductions); + + if (fuseReductions) { + BRepAlgoAPI_Fuse fuseInci (aResult, aReductionInci); + if (!fuseInci.IsDone()) + StdFail_NotDone::Raise("Cannot fuse Te with incident reduction"); + aResult = fuseInci.Shape(); + } + else { + BRep_Builder B; + TopoDS_Compound C; + B.MakeCompound(C); + B.Add(C, aResult); + B.Add(C, aReductionInci); + aResult = C; + } + } + + // Get rid of extra compounds + TopTools_ListOfShape listShapeRes; + GEOMUtils::AddSimpleShapes(aResult, listShapeRes); + aResult = listShapeRes.First(); // useful for the case "fuseReductions == true" + + if (!fuseReductions && listShapeRes.Extent() > 1) { + // Simplify T-Shape compound (get rid of sub-compounds) and glue duplicated faces + BRep_Builder B; + TopoDS_Compound C; + B.MakeCompound(C); + + TopTools_ListIteratorOfListOfShape itSub (listShapeRes); + for (; itSub.More(); itSub.Next()) + B.Add(C, itSub.Value()); + + // GlueFaces + aResult = GEOMImpl_GlueDriver::GlueFaces(C, Precision::Confusion(), Standard_True); + } + + return aResult; +} + +//======================================================================= +//function : MakeThicknessReduction +//purpose : Static method. Create one thickness reduction element. +//======================================================================= +TopoDS_Shape GEOMImpl_IAdvancedOperations::MakeThicknessReduction (gp_Ax2 theAxes, + const double R, const double W, + const double Rthin, const double Wthin, + const double Ltrans, const double Lthin, + bool fuse) +{ + double aTol = Precision::Confusion(); + if (Rthin < aTol || Wthin < aTol || Ltrans < aTol) { + StdFail_NotDone::Raise("Cannot build thickness reduction: too small values"); + } + bool isThinPart = (Lthin > aTol); + + // . + // W |\ + // . \ + // ^ \ '-----------------. + // |R \| | Wthin + // | '-----------------' + // v Rthin + // --.--.--.--.--.--.--.--.--.--.--.--.--> theAxes.Direction() + // Ltrans Lthin + + double RExt = R + W; + double RthinExt = Rthin + Wthin; + + gp_Dir aNormal = theAxes.Direction(); + gp_Dir anXDir = theAxes.XDirection(); + gp_Pnt aPntCyl (theAxes.Location().XYZ() + aNormal.XYZ()*Ltrans); + gp_Ax2 anAxesCyl (aPntCyl, aNormal, anXDir); + + // Build the transition part + BRepPrimAPI_MakeCone ConeExt (theAxes, RExt, RthinExt, Ltrans); + BRepPrimAPI_MakeCone ConeInt (theAxes, R, Rthin, Ltrans); + ConeExt.Build(); + ConeInt.Build(); + if (!ConeExt.IsDone() || !ConeInt.IsDone()) + StdFail_NotDone::Raise("Cannot build cones of thickness reduction"); + BRepAlgoAPI_Cut cut1 (ConeExt.Shape(), ConeInt.Shape()); + if (!cut1.IsDone()) + StdFail_NotDone::Raise("Coudn't build transition part of thickness reduction"); + TopoDS_Shape aReduction = cut1.Shape(); + + // Build the thin part, if required + TopoDS_Shape aThinPart; + if (isThinPart) { + BRepPrimAPI_MakeCylinder CExt (anAxesCyl, RthinExt, Lthin); + BRepPrimAPI_MakeCylinder CInt (anAxesCyl, Rthin, Lthin); + CExt.Build(); + CInt.Build(); + if (!CExt.IsDone() || !CInt.IsDone()) + StdFail_NotDone::Raise("Cannot build cylinders of thickness reduction"); + BRepAlgoAPI_Cut cut2 (CExt.Shape(), CInt.Shape()); + if (!cut2.IsDone()) + StdFail_NotDone::Raise("Coudn't build thin part of thickness reduction"); + aThinPart = cut2.Shape(); + } + + // Join parts + if (fuse) { + if (isThinPart) { + BRepAlgoAPI_Fuse fuse1 (aReduction, aThinPart); + if (!fuse1.IsDone()) + StdFail_NotDone::Raise("Cannot fuse parts of thickness reduction"); + aReduction = fuse1.Shape(); + } + } + else { + // Partition the reduction on blocks + gp_Ax3 anAxesPln1 (aPntCyl, theAxes.XDirection(), aNormal); + gp_Ax3 anAxesPln2 (aPntCyl, theAxes.YDirection(), aNormal); + gp_Pln aPln1 (anAxesPln1); + gp_Pln aPln2 (anAxesPln2); + double aSize = Ltrans + Lthin + R + Rthin + Wthin; // to guarantee enough size in all directions + TopoDS_Shape aTool1 = BRepBuilderAPI_MakeFace(aPln1, -aSize, +aSize, -aSize, +aSize).Shape(); + TopoDS_Shape aTool2 = BRepBuilderAPI_MakeFace(aPln2, -aSize, +aSize, -aSize, +aSize).Shape(); + + GEOMAlgo_Splitter PS; + PS.AddShape(aReduction); + if (isThinPart) + PS.AddShape(aThinPart); + PS.AddTool(aTool1); + PS.AddTool(aTool2); + PS.SetLimit(TopAbs_SOLID); + PS.Perform(); + + aReduction = PS.Shape(); + } + + return aReduction; +} + +//============================================================================= +/*! + * MakePipeTShape + * \brief Create a T-shape object with specified caracteristics for the main and + * the incident pipes (radius, width, half-length). + * Center of the shape is (0,0,0). The main plane of the T-shape is XOY. + * \param theR1 Internal radius of main pipe + * \param theW1 Width of main pipe + * \param theL1 Half-length of main pipe + * \param theR2 Internal radius of incident pipe (R2 < R1) + * \param theW2 Width of incident pipe (R2+W2 < R1+W1) + * \param theL2 Half-length of incident pipe + * \param theHexMesh Boolean indicating if shape is prepared for hex mesh + * \return List of GEOM_Objects, containing the created shape and propagation groups. + */ +//============================================================================= +Handle(TColStd_HSequenceOfTransient) + GEOMImpl_IAdvancedOperations::MakePipeTShape(double theR1, double theW1, double theL1, + double theR2, double theW2, double theL2, + double theRL, double theWL, double theLtransL, double theLthinL, + double theRR, double theWR, double theLtransR, double theLthinR, + double theRI, double theWI, double theLtransI, double theLthinI, + bool theHexMesh) +{ + MESSAGE("GEOMImpl_IAdvancedOperations::MakePipeTShape"); + SetErrorCode(KO); + //Add a new object + Handle(GEOM_Object) aShape = GetEngine()->AddObject(GetDocID(), GEOM_TSHAPE); + + //Add a new shape function with parameters + Handle(GEOM_Function) aFunction = aShape->AddFunction(GEOMImpl_PipeTShapeDriver::GetID(), TSHAPE_BASIC); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_PipeTShapeDriver::GetID()) return NULL; + + GEOMImpl_IPipeTShape aData (aFunction); + + aData.SetR1(theR1); + aData.SetW1(theW1); + aData.SetL1(theL1); + aData.SetR2(theR2); + aData.SetW2(theW2); + aData.SetL2(theL2); + aData.SetHexMesh(theHexMesh); + + bool isTRL = (theRL + theWL + theLtransL + theLthinL) > Precision::Confusion(); + bool isTRR = (theRR + theWR + theLtransR + theLthinR) > Precision::Confusion(); + bool isTRI = (theRI + theWI + theLtransI + theLthinI) > Precision::Confusion(); + + //Compute the resulting value + try { +#if OCC_VERSION_LARGE > 0x06010000 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("TShape driver failed"); + return NULL; + } + + if (theHexMesh) { + if (!MakePipeTShapePartition(aShape, theR1, theW1, theL1, theR2, theW2, theL2)) + return NULL; + if (!MakePipeTShapeMirrorAndGlue(aShape, theR1, theW1, theL1, theR2, theW2, theL2)) + return NULL; + } + + if (isTRL || isTRR || isTRI) { + // Add thickness reduction elements + // at the three extremities: Left, Right and Incident + TopoDS_Shape aResShape = + MakePipeTShapeThicknessReduction(aShape->GetValue(), theR1, theW1, theL1, theR2, theW2, theL2, + theRL, theWL, theLtransL, theLthinL, + theRR, theWR, theLtransR, theLthinR, + theRI, theWI, theLtransI, theLthinI, + !theHexMesh); + aFunction->SetValue(aResShape); + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient; + aSeq->Append(aShape); + + try { + if (theHexMesh) { + // Get the groups + if (!MakeGroups(aShape, TSHAPE_BASIC, theR1, theW1, theL1, theR2, theW2, theL2, + 0., 0., 0., aSeq, gp_Trsf())) + return NULL; + } + + // Get internal group. + if (!MakeInternalGroup(aShape, theR1, theL1, theR2, theL2, theRL, theLtransL, + theRR, theLtransR, theRI, theLtransI, + aSeq, gp_Trsf())) { + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //Make a Python command + TCollection_AsciiString anEntry, aListRes("["); + // Iterate over the sequence aSeq + Standard_Integer aNbGroups = aSeq->Length(); + Standard_Integer i = 1; + for (; i <= aNbGroups; i++) { + Handle(Standard_Transient) anItem = aSeq->Value(i); + if (anItem.IsNull()) continue; + Handle(GEOM_Object) aGroup = Handle(GEOM_Object)::DownCast(anItem); + if (aGroup.IsNull()) continue; + //Make a Python command + TDF_Tool::Entry(aGroup->GetEntry(), anEntry); + aListRes += anEntry + ", "; + } + aListRes.Trunc(aListRes.Length() - 2); + + GEOM::TPythonDump pd (aFunction); + + pd << aListRes.ToCString() << "] = geompy.MakePipeTShape(" + << theR1 << ", " << theW1 << ", " << theL1 << ", " + << theR2 << ", " << theW2 << ", " << theL2 << ", " + << theHexMesh; + + // thickness reduction + if (isTRL) + pd << ", theRL=" << theRL << ", theWL=" << theWL + << ", theLtransL=" << theLtransL << ", theLthinL=" << theLthinL; + if (isTRR) + pd << ", theRR=" << theRR << ", theWR=" << theWR + << ", theLtransR=" << theLtransR << ", theLthinR=" << theLthinR; + if (isTRI) + pd << ", theRI=" << theRI << ", theWI=" << theWI + << ", theLtransI=" << theLtransI << ", theLthinI=" << theLthinI; + + pd << ")"; + + SetErrorCode(OK); + + return aSeq; +} + +//============================================================================= +/*! + * MakePipeTShapeWithPosition + * Create a T-shape object with specified caracteristics for the main and + * the incident pipes (radius, width, half-length). + * The extremities of the main pipe are located on junctions points P1 and P2. + * The extremity of the incident pipe is located on junction point P3. + * \param theR1 Internal radius of main pipe + * \param theW1 Width of main pipe + * \param theL1 Half-length of main pipe + * \param theR2 Internal radius of incident pipe (R2 < R1) + * \param theW2 Width of incident pipe (R2+W2 < R1+W1) + * \param theL2 Half-length of incident pipe + * \param theHexMesh Boolean indicating if shape is prepared for hex mesh + * \param theP1 1st junction point of main pipe + * \param theP2 2nd junction point of main pipe + * \param theP3 Junction point of incident pipe + * \return List of GEOM_Objects, containing the created shape and propagation groups.. + */ +//============================================================================= +Handle(TColStd_HSequenceOfTransient) +GEOMImpl_IAdvancedOperations::MakePipeTShapeWithPosition + (double theR1, double theW1, double theL1, + double theR2, double theW2, double theL2, + double theRL, double theWL, double theLtransL, double theLthinL, + double theRR, double theWR, double theLtransR, double theLthinR, + double theRI, double theWI, double theLtransI, double theLthinI, + bool theHexMesh, + Handle(GEOM_Object) theP1, + Handle(GEOM_Object) theP2, + Handle(GEOM_Object) theP3) +{ + SetErrorCode(KO); + //Add a new object + Handle(GEOM_Object) aShape = GetEngine()->AddObject(GetDocID(), GEOM_TSHAPE); + ///////////////// + // TSHAPE CODE + ///////////////// + //Add a new shape function with parameters + Handle(GEOM_Function) aFunction = aShape->AddFunction(GEOMImpl_PipeTShapeDriver::GetID(), TSHAPE_BASIC); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_PipeTShapeDriver::GetID()) return NULL; + + // Check new position + if (!CheckCompatiblePosition(theL1, theL2, theP1, theP2, theP3, 0.01)) { + return NULL; + } + + GEOMImpl_IPipeTShape aData(aFunction); + + aData.SetR1(theR1); + aData.SetW1(theW1); + aData.SetL1(theL1); + aData.SetR2(theR2); + aData.SetW2(theW2); + aData.SetL2(theL2); + aData.SetHexMesh(theHexMesh); + + bool isTRL = (theRL + theWL + theLtransL + theLthinL) > Precision::Confusion(); + bool isTRR = (theRR + theWR + theLtransR + theLthinR) > Precision::Confusion(); + bool isTRI = (theRI + theWI + theLtransI + theLthinI) > Precision::Confusion(); + + //Compute the resulting value + try { +#if OCC_VERSION_LARGE > 0x06010000 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("TShape driver failed"); + return NULL; + } + + if (theHexMesh) { + if (!MakePipeTShapePartition(aShape, theR1, theW1, theL1, theR2, theW2, theL2)) + return NULL; + if (!MakePipeTShapeMirrorAndGlue(aShape, theR1, theW1, theL1, theR2, theW2, theL2)) + return NULL; + } + + if (isTRL || isTRR || isTRI) { + // Add thickness reduction elements + // at the three extremities: Left, Right and Incident + TopoDS_Shape aResShape = + MakePipeTShapeThicknessReduction(aShape->GetValue(), theR1, theW1, theL1, theR2, theW2, theL2, + theRL, theWL, theLtransL, theLthinL, + theRR, theWR, theLtransR, theLthinR, + theRI, theWI, theLtransI, theLthinI, + !theHexMesh); + aFunction->SetValue(aResShape); + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + TopoDS_Shape Te = aShape->GetValue(); + + // Set Position + gp_Trsf aTrsf = GetPositionTrsf(theL1, theL2, theP1, theP2, theP3); + BRepBuilderAPI_Transform aTransformation(Te, aTrsf, Standard_False); + TopoDS_Shape aTrsf_Shape = aTransformation.Shape(); + aFunction->SetValue(aTrsf_Shape); + + Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient; + aSeq->Append(aShape); + + try { + if (theHexMesh) { + // Get the groups + if (!MakeGroups(aShape,TSHAPE_BASIC, theR1, theW1, theL1, theR2, theW2, theL2, + 0., 0., 0., aSeq, aTrsf)) { + return NULL; + } + } + + // Get internal group. + if (!MakeInternalGroup(aShape, theR1, theL1, theR2, theL2, theRL, theLtransL, + theRR, theLtransR, theRI, theLtransI, + aSeq, aTrsf)) { + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //Make a Python command + TCollection_AsciiString anEntry, aListRes("["); + // Iterate over the sequence aSeq + Standard_Integer aNbGroups = aSeq->Length(); + Standard_Integer i = 1; + for (; i <= aNbGroups; i++) { + Handle(Standard_Transient) anItem = aSeq->Value(i); + if (anItem.IsNull()) continue; + Handle(GEOM_Object) aGroup = Handle(GEOM_Object)::DownCast(anItem); + if (aGroup.IsNull()) continue; + //Make a Python command + TDF_Tool::Entry(aGroup->GetEntry(), anEntry); + aListRes += anEntry + ", "; + } + aListRes.Trunc(aListRes.Length() - 2); + + GEOM::TPythonDump pd (aFunction); + + pd << aListRes.ToCString() << "] = geompy.MakePipeTShape(" + << theR1 << ", " << theW1 << ", " << theL1 << ", " + << theR2 << ", " << theW2 << ", " << theL2 << ", " + << theHexMesh << ", " << theP1 << ", " << theP2 << ", " << theP3; + + // thickness reduction + if (isTRL) + pd << ", theRL=" << theRL << ", theWL=" << theWL + << ", theLtransL=" << theLtransL << ", theLthinL=" << theLthinL; + if (isTRR) + pd << ", theRR=" << theRR << ", theWR=" << theWR + << ", theLtransR=" << theLtransR << ", theLthinR=" << theLthinR; + if (isTRI) + pd << ", theRI=" << theRI << ", theWI=" << theWI + << ", theLtransI=" << theLtransI << ", theLthinI=" << theLthinI; + + pd << ")"; + + SetErrorCode(OK); + + return aSeq; +} + +//============================================================================= +/*! + * MakePipeTShapeChamfer + * Create a T-shape object with specified caracteristics for the main and + * the incident pipes (radius, width, half-length). A chamfer is created + * on the junction of the pipes. + * Center of the shape is (0,0,0). The main plane of the T-shape is XOY. + * \param theR1 Internal radius of main pipe + * \param theW1 Width of main pipe + * \param theL1 Half-length of main pipe + * \param theR2 Internal radius of incident pipe (R2 < R1) + * \param theW2 Width of incident pipe (R2+W2 < R1+W1) + * \param theL2 Half-length of incident pipe + * \param theH Height of chamfer. + * \param theW Width of chamfer. + * \param theHexMesh Boolean indicating if shape is prepared for hex mesh + * \return List of GEOM_Objects, containing the created shape and propagation groups. + */ +//============================================================================= +Handle(TColStd_HSequenceOfTransient) +GEOMImpl_IAdvancedOperations::MakePipeTShapeChamfer + (double theR1, double theW1, double theL1, + double theR2, double theW2, double theL2, + double theRL, double theWL, double theLtransL, double theLthinL, + double theRR, double theWR, double theLtransR, double theLthinR, + double theRI, double theWI, double theLtransI, double theLthinI, + double theH, double theW, + bool theHexMesh) +{ + SetErrorCode(KO); + //Add a new object + Handle(GEOM_Object) aShape = GetEngine()->AddObject(GetDocID(), GEOM_TSHAPE); + //Add a new shape function with parameters + Handle(GEOM_Function) aFunction = aShape->AddFunction(GEOMImpl_PipeTShapeDriver::GetID(), TSHAPE_CHAMFER); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_PipeTShapeDriver::GetID()) return NULL; + + GEOMImpl_IPipeTShape aData(aFunction); + + aData.SetR1(theR1); + aData.SetW1(theW1); + aData.SetL1(theL1); + aData.SetR2(theR2); + aData.SetW2(theW2); + aData.SetL2(theL2); + aData.SetH(theH); + aData.SetW(theW); + aData.SetHexMesh(theHexMesh); + + bool isTRL = (theRL + theWL + theLtransL + theLthinL) > Precision::Confusion(); + bool isTRR = (theRR + theWR + theLtransR + theLthinR) > Precision::Confusion(); + bool isTRI = (theRI + theWI + theLtransI + theLthinI) > Precision::Confusion(); + + //Compute the resulting value + try { +#if OCC_VERSION_LARGE > 0x06010000 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("TShape driver failed"); + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + // BEGIN of chamfer + TopoDS_Shape aShapeShape = aShape->GetValue(); + TopTools_IndexedMapOfShape anEdgesIndices; + TopExp::MapShapes(aShapeShape, anEdgesIndices); + // Common edges on external cylinders + Handle(GEOM_Object) box_e; + if (theHexMesh) { + box_e = my3DPrimOperations->MakeBoxDXDYDZ(theR2+theW2, theR2+theW2, theR1+theW1); + } + else { + box_e = my3DPrimOperations->MakeBoxDXDYDZ(2*(theR2+theW2), 2*(theR2+theW2), theR1+theW1); + } + box_e->GetLastFunction()->SetDescription(""); + box_e = myTransformOperations->TranslateDXDYDZ(box_e, -(theR2+theW2), -(theR2+theW2), 0); + box_e->GetLastFunction()->SetDescription(""); + + Handle(TColStd_HSequenceOfInteger) edges_e = + myShapesOperations->GetShapesOnBoxIDs(box_e, aShape, TopAbs_EDGE, GEOMAlgo_ST_IN); + box_e->GetLastFunction()->SetDescription(""); + + if (edges_e.IsNull() || edges_e->Length() == 0) { + SetErrorCode("External edges not found"); + return NULL; + } + int nbEdgesInChamfer = 0; + std::list theEdges; + for (int i=1; i<=edges_e->Length();i++) { + int edgeID = edges_e->Value(i); + TopoDS_Shape theEdge = anEdgesIndices.FindKey(edgeID); + TopExp_Explorer Ex(theEdge,TopAbs_VERTEX); + int iv=0; + while (Ex.More()) { + iv ++; + gp_Pnt aPt = BRep_Tool::Pnt(TopoDS::Vertex(Ex.Current())); + if (Abs(aPt.Z() - (theR1+theW1)) <= Precision::Confusion()) { + nbEdgesInChamfer ++; + theEdges.push_back(edgeID); + } + Ex.Next(); + } + if (theHexMesh && nbEdgesInChamfer == 1) + break; + } + Handle(GEOM_Object) aChamfer; + try { + aChamfer = myLocalOperations->MakeChamferEdges(aShape, theW, theH, theEdges); + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + if (aChamfer.IsNull()) { + SetErrorCode("Chamfer can not be computed on the given shape with the given parameters"); + return NULL; + } + aChamfer->GetLastFunction()->SetDescription(""); + + TopoDS_Shape aChamferShape = aChamfer->GetValue(); + aFunction->SetValue(aChamferShape); + // END of chamfer + + if (theHexMesh) { + if (!MakePipeTShapePartition(aShape, theR1, theW1, theL1, theR2, theW2, theL2, theH, theW, 0, false)) + return NULL; + if (!MakePipeTShapeMirrorAndGlue(aShape, theR1, theW1, theL1, theR2, theW2, theL2)) + return NULL; + } + + // Add thickness reduction elements + // at the three extremities: Left, Right and Incident + try { +#if OCC_VERSION_LARGE > 0x06010000 + OCC_CATCH_SIGNALS; +#endif + if (isTRL || isTRR || isTRI) { + TopoDS_Shape aResShape = + MakePipeTShapeThicknessReduction(aShape->GetValue(), theR1, theW1, theL1, theR2, theW2, theL2, + theRL, theWL, theLtransL, theLthinL, + theRR, theWR, theLtransR, theLthinR, + theRI, theWI, theLtransI, theLthinI, + !theHexMesh); + aFunction->SetValue(aResShape); + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient; + aSeq->Append(aShape); + + try { + if (theHexMesh) { + // Get the groups + if (!MakeGroups(aShape, TSHAPE_CHAMFER, theR1, theW1, theL1, theR2, theW2, theL2, + theH, theW, 0., aSeq, gp_Trsf())) + return NULL; + } + + // Get internal group. + if (!MakeInternalGroup(aShape, theR1, theL1, theR2, theL2, theRL, theLtransL, + theRR, theLtransR, theRI, theLtransI, + aSeq, gp_Trsf())) { + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //Make a Python command + TCollection_AsciiString anEntry, aListRes("["); + // Iterate over the sequence aSeq + Standard_Integer aNbGroups = aSeq->Length(); + Standard_Integer i = 1; + for (; i <= aNbGroups; i++) { + Handle(Standard_Transient) anItem = aSeq->Value(i); + if (anItem.IsNull()) continue; + Handle(GEOM_Object) aGroup = Handle(GEOM_Object)::DownCast(anItem); + if (aGroup.IsNull()) continue; + //Make a Python command + TDF_Tool::Entry(aGroup->GetEntry(), anEntry); + aListRes += anEntry + ", "; + } + aListRes.Trunc(aListRes.Length() - 2); + + GEOM::TPythonDump pd (aFunction); + + pd << aListRes.ToCString() << "] = geompy.MakePipeTShapeChamfer(" + << theR1 << ", " << theW1 << ", " << theL1 << ", " + << theR2 << ", " << theW2 << ", " << theL2 << ", " + << theH << ", " << theW << ", " << theHexMesh; + + // thickness reduction + if (isTRL) + pd << ", theRL=" << theRL << ", theWL=" << theWL + << ", theLtransL=" << theLtransL << ", theLthinL=" << theLthinL; + if (isTRR) + pd << ", theRR=" << theRR << ", theWR=" << theWR + << ", theLtransR=" << theLtransR << ", theLthinR=" << theLthinR; + if (isTRI) + pd << ", theRI=" << theRI << ", theWI=" << theWI + << ", theLtransI=" << theLtransI << ", theLthinI=" << theLthinI; + + pd << ")"; + + SetErrorCode(OK); + + return aSeq; +} + +//============================================================================= +/*! + * MakePipeTShapeChamferWithPosition + * Create a T-shape object with specified caracteristics for the main and + * the incident pipes (radius, width, half-length). A chamfer is created + * on the junction of the pipes. + * The extremities of the main pipe are located on junctions points P1 and P2. + * The extremity of the incident pipe is located on junction point P3. + * \param theR1 Internal radius of main pipe + * \param theW1 Width of main pipe + * \param theL1 Half-length of main pipe + * \param theR2 Internal radius of incident pipe (R2 < R1) + * \param theW2 Width of incident pipe (R2+W2 < R1+W1) + * \param theL2 Half-length of incident pipe + * \param theH Height of chamfer. + * \param theW Width of chamfer. + * \param theHexMesh Boolean indicating if shape is prepared for hex mesh + * \param theP1 1st junction point of main pipe + * \param theP2 2nd junction point of main pipe + * \param theP3 Junction point of incident pipe + * \return List of GEOM_Objects, containing the created shape and propagation groups. + */ +//============================================================================= +Handle(TColStd_HSequenceOfTransient) +GEOMImpl_IAdvancedOperations::MakePipeTShapeChamferWithPosition + (double theR1, double theW1, double theL1, + double theR2, double theW2, double theL2, + double theRL, double theWL, double theLtransL, double theLthinL, + double theRR, double theWR, double theLtransR, double theLthinR, + double theRI, double theWI, double theLtransI, double theLthinI, + double theH, double theW, + bool theHexMesh, + Handle(GEOM_Object) theP1, + Handle(GEOM_Object) theP2, + Handle(GEOM_Object) theP3) +{ + SetErrorCode(KO); + //Add a new object + Handle(GEOM_Object) aShape = GetEngine()->AddObject(GetDocID(), GEOM_TSHAPE); + //Add a new shape function with parameters + Handle(GEOM_Function) aFunction = aShape->AddFunction(GEOMImpl_PipeTShapeDriver::GetID(), TSHAPE_CHAMFER); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_PipeTShapeDriver::GetID()) return NULL; + + // Check new position + if (!CheckCompatiblePosition(theL1, theL2, theP1, theP2, theP3, 0.01)) { + return NULL; + } + + GEOMImpl_IPipeTShape aData(aFunction); + + aData.SetR1(theR1); + aData.SetW1(theW1); + aData.SetL1(theL1); + aData.SetR2(theR2); + aData.SetW2(theW2); + aData.SetL2(theL2); + aData.SetH(theH); + aData.SetW(theW); + aData.SetHexMesh(theHexMesh); + + bool isTRL = (theRL + theWL + theLtransL + theLthinL) > Precision::Confusion(); + bool isTRR = (theRR + theWR + theLtransR + theLthinR) > Precision::Confusion(); + bool isTRI = (theRI + theWI + theLtransI + theLthinI) > Precision::Confusion(); + + //Compute the resulting value + try { +#if OCC_VERSION_LARGE > 0x06010000 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("TShape driver failed"); + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + // BEGIN of chamfer + TopoDS_Shape aShapeShape = aShape->GetValue(); + TopTools_IndexedMapOfShape anEdgesIndices; + TopExp::MapShapes(aShapeShape, anEdgesIndices); + // Common edges on external cylinders + Handle(GEOM_Object) box_e; + if (theHexMesh) { + box_e = my3DPrimOperations->MakeBoxDXDYDZ(theR2+theW2, theR2+theW2, theR1+theW1); + } + else { + box_e = my3DPrimOperations->MakeBoxDXDYDZ(2*(theR2+theW2), 2*(theR2+theW2), theR1+theW1); + } + box_e->GetLastFunction()->SetDescription(""); + box_e = myTransformOperations->TranslateDXDYDZ(box_e, -(theR2+theW2), -(theR2+theW2), 0); + box_e->GetLastFunction()->SetDescription(""); + + Handle(TColStd_HSequenceOfInteger) edges_e = + myShapesOperations->GetShapesOnBoxIDs(box_e, aShape, TopAbs_EDGE, GEOMAlgo_ST_IN); + box_e->GetLastFunction()->SetDescription(""); + + if (edges_e.IsNull() || edges_e->Length() == 0) { + SetErrorCode("External edges not found"); + return NULL; + } + int nbEdgesInChamfer = 0; + std::list theEdges; + for (int i=1; i<=edges_e->Length();i++) { + int edgeID = edges_e->Value(i); + TopoDS_Shape theEdge = anEdgesIndices.FindKey(edgeID); + TopExp_Explorer Ex(theEdge,TopAbs_VERTEX); + while (Ex.More()) { + gp_Pnt aPt = BRep_Tool::Pnt(TopoDS::Vertex(Ex.Current())); + if (Abs(aPt.Z() - (theR1+theW1)) <= Precision::Confusion()) { + nbEdgesInChamfer ++; + theEdges.push_back(edgeID); + } + Ex.Next(); + } + if (theHexMesh && nbEdgesInChamfer == 1) + break; + } + Handle(GEOM_Object) aChamfer; + try { + aChamfer = myLocalOperations->MakeChamferEdges(aShape, theW, theH, theEdges); + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + if (aChamfer.IsNull()) { + SetErrorCode("Chamfer can not be computed on the given shape with the given parameters"); + return NULL; + } + aChamfer->GetLastFunction()->SetDescription(""); + + TopoDS_Shape aChamferShape = aChamfer->GetValue(); + aFunction->SetValue(aChamferShape); + // END of chamfer + + if (theHexMesh) { + if (!MakePipeTShapePartition(aShape, theR1, theW1, theL1, theR2, theW2, theL2, theH, theW, 0, false)) + return NULL; + if (!MakePipeTShapeMirrorAndGlue(aShape, theR1, theW1, theL1, theR2, theW2, theL2)) + return NULL; + } + + // Add thickness reduction elements + // at the three extremities: Left, Right and Incident + try { +#if OCC_VERSION_LARGE > 0x06010000 + OCC_CATCH_SIGNALS; +#endif + if (isTRL || isTRR || isTRI) { + TopoDS_Shape aResShape = + MakePipeTShapeThicknessReduction(aShape->GetValue(), theR1, theW1, theL1, theR2, theW2, theL2, + theRL, theWL, theLtransL, theLthinL, + theRR, theWR, theLtransR, theLthinR, + theRI, theWI, theLtransI, theLthinI, + !theHexMesh); + aFunction->SetValue(aResShape); + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + // Set Position + gp_Trsf aTrsf = GetPositionTrsf(theL1, theL2, theP1, theP2, theP3); + BRepBuilderAPI_Transform aTransformation (aShape->GetValue(), aTrsf, Standard_False); + TopoDS_Shape aTrsf_Shape = aTransformation.Shape(); + aFunction->SetValue(aTrsf_Shape); + + Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient; + aSeq->Append(aShape); + + try { + if (theHexMesh) { + // Get the groups + if (!MakeGroups(aShape, TSHAPE_CHAMFER, theR1, theW1, theL1, theR2, theW2, theL2, + theH, theW, 0., aSeq, aTrsf)) + return NULL; + } + + // Get internal group. + if (!MakeInternalGroup(aShape, theR1, theL1, theR2, theL2, theRL, theLtransL, + theRR, theLtransR, theRI, theLtransI, + aSeq, aTrsf)) { + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //Make a Python command + TCollection_AsciiString anEntry, aListRes("["); + // Iterate over the sequence aSeq + Standard_Integer aNbGroups = aSeq->Length(); + Standard_Integer i = 1; + for (; i <= aNbGroups; i++) { + Handle(Standard_Transient) anItem = aSeq->Value(i); + if (anItem.IsNull()) continue; + Handle(GEOM_Object) aGroup = Handle(GEOM_Object)::DownCast(anItem); + if (aGroup.IsNull()) continue; + //Make a Python command + TDF_Tool::Entry(aGroup->GetEntry(), anEntry); + aListRes += anEntry + ", "; + } + aListRes.Trunc(aListRes.Length() - 2); + + GEOM::TPythonDump pd (aFunction); + + pd << aListRes.ToCString() << "] = geompy.MakePipeTShapeChamfer(" + << theR1 << ", " << theW1 << ", " << theL1 << ", " + << theR2 << ", " << theW2 << ", " << theL2 << ", " + << theH << ", " << theW << ", " << theHexMesh << ", " + << theP1 << ", " << theP2 << ", " << theP3; + + // thickness reduction + if (isTRL) + pd << ", theRL=" << theRL << ", theWL=" << theWL + << ", theLtransL=" << theLtransL << ", theLthinL=" << theLthinL; + if (isTRR) + pd << ", theRR=" << theRR << ", theWR=" << theWR + << ", theLtransR=" << theLtransR << ", theLthinR=" << theLthinR; + if (isTRI) + pd << ", theRI=" << theRI << ", theWI=" << theWI + << ", theLtransI=" << theLtransI << ", theLthinI=" << theLthinI; + + pd << ")"; + + SetErrorCode(OK); + + return aSeq; +} + +//============================================================================= +/*! + * MakePipeTShapeFillet + * Create a T-shape object with specified caracteristics for the main and + * the incident pipes (radius, width, half-length). A fillet is created + * on the junction of the pipes. + * Center of the shape is (0,0,0). The main plane of the T-shape is XOY. + * \param theR1 Internal radius of main pipe + * \param theW1 Width of main pipe + * \param theL1 Half-length of main pipe + * \param theR2 Internal radius of incident pipe (R2 < R1) + * \param theW2 Width of incident pipe (R2+W2 < R1+W1) + * \param theL2 Half-length of incident pipe + * \param theRF Radius of curvature of fillet. + * \param theHexMesh Boolean indicating if shape is prepared for hex mesh + * \return List of GEOM_Objects, containing the created shape and propagation groups. + */ +//============================================================================= +Handle(TColStd_HSequenceOfTransient) +GEOMImpl_IAdvancedOperations::MakePipeTShapeFillet + (double theR1, double theW1, double theL1, + double theR2, double theW2, double theL2, + double theRL, double theWL, double theLtransL, double theLthinL, + double theRR, double theWR, double theLtransR, double theLthinR, + double theRI, double theWI, double theLtransI, double theLthinI, + double theRF, bool theHexMesh) +{ + SetErrorCode(KO); + //Add a new object + Handle(GEOM_Object) aShape = GetEngine()->AddObject(GetDocID(), GEOM_TSHAPE); + //Add a new shape function with parameters + Handle(GEOM_Function) aFunction = aShape->AddFunction(GEOMImpl_PipeTShapeDriver::GetID(), TSHAPE_FILLET); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_PipeTShapeDriver::GetID()) return NULL; + + GEOMImpl_IPipeTShape aData(aFunction); + + aData.SetR1(theR1); + aData.SetW1(theW1); + aData.SetL1(theL1); + aData.SetR2(theR2); + aData.SetW2(theW2); + aData.SetL2(theL2); + aData.SetRF(theRF); + aData.SetHexMesh(theHexMesh); + + bool isTRL = (theRL + theWL + theLtransL + theLthinL) > Precision::Confusion(); + bool isTRR = (theRR + theWR + theLtransR + theLthinR) > Precision::Confusion(); + bool isTRI = (theRI + theWI + theLtransI + theLthinI) > Precision::Confusion(); + + //Compute the resulting value + try { +#if OCC_VERSION_LARGE > 0x06010000 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("TShape driver failed"); + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + // BEGIN of fillet + TopoDS_Shape aShapeShape = aShape->GetValue(); + TopTools_IndexedMapOfShape anEdgesIndices; + TopExp::MapShapes(aShapeShape, anEdgesIndices); + // Common edges on external cylinders + Handle(GEOM_Object) box_e; + if (theHexMesh) { + box_e = my3DPrimOperations->MakeBoxDXDYDZ(theR2+theW2, theR2+theW2, theR1+theW1); + } + else { + box_e = my3DPrimOperations->MakeBoxDXDYDZ(2*(theR2+theW2), 2*(theR2+theW2), theR1+theW1); + } + box_e->GetLastFunction()->SetDescription(""); + box_e = myTransformOperations->TranslateDXDYDZ(box_e, -(theR2+theW2), -(theR2+theW2), 0); + box_e->GetLastFunction()->SetDescription(""); + + Handle(TColStd_HSequenceOfInteger) edges_e = + myShapesOperations->GetShapesOnBoxIDs(box_e, aShape, TopAbs_EDGE, GEOMAlgo_ST_IN); + box_e->GetLastFunction()->SetDescription(""); + + if (edges_e.IsNull() || edges_e->Length() == 0) { + SetErrorCode("External edges not found"); + return NULL; + } + int nbEdgesInFillet = 0; + std::list theEdges; + for (int i=1; i<=edges_e->Length();i++) { + int edgeID = edges_e->Value(i); + TopoDS_Shape theEdge = anEdgesIndices.FindKey(edgeID); + TopExp_Explorer Ex(theEdge,TopAbs_VERTEX); + while (Ex.More()) { + gp_Pnt aPt = BRep_Tool::Pnt(TopoDS::Vertex(Ex.Current())); + if (Abs(aPt.Z() - (theR1+theW1)) <= Precision::Confusion()) { + nbEdgesInFillet ++; + theEdges.push_back(edgeID); + } + Ex.Next(); + } + if (theHexMesh && nbEdgesInFillet == 1) + break; + } + + Handle(GEOM_Object) aFillet; + try { + aFillet = myLocalOperations->MakeFilletEdges(aShape, theRF, theEdges); + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + if (aFillet.IsNull()) { + //SetErrorCode("Fillet can not be computed on the given shape with the given parameters"); + SetErrorCode(myLocalOperations->GetErrorCode()); + return NULL; + } + aFillet->GetLastFunction()->SetDescription(""); + + TopoDS_Shape aFilletShape = aFillet->GetValue(); + aFunction->SetValue(aFilletShape); + // END of fillet + +// VSR: debug issues 0021568 and 0021550 (15/05/2012) - BEGIN (1) +// the following block, when enabled, leads to partitioning problems +#if 0 +// VSR: debug issues 0021568 and 0021550 (15/05/2012) - END (1) + // BEGIN: Limit tolerances (debug) + Handle(GEOM_Object) aCorr1 = myHealingOperations->LimitTolerance(aShape, 1e-07); + TopoDS_Shape aCorr1Shape = aCorr1->GetValue(); + aShape->GetLastFunction()->SetValue(aCorr1Shape); + aCorr1->GetLastFunction()->SetDescription(""); + // END: Limit tolerances (debug) +// VSR: debug issues 0021568 and 0021550 (15/05/2012) - BEGIN (2) +#endif +// VSR: debug issues 0021568 and 0021550 (15/05/2012) - END (2) + + if (theHexMesh) { + if (!MakePipeTShapePartition(aShape, theR1, theW1, theL1, theR2, theW2, theL2, 0, 0, theRF, false)) + return NULL; + if (!MakePipeTShapeMirrorAndGlue(aShape, theR1, theW1, theL1, theR2, theW2, theL2)) + return NULL; + } + + // Add thickness reduction elements + // at the three extremities: Left, Right and Incident + try { +#if OCC_VERSION_LARGE > 0x06010000 + OCC_CATCH_SIGNALS; +#endif + if (isTRL || isTRR || isTRI) { + TopoDS_Shape aResShape = + MakePipeTShapeThicknessReduction(aShape->GetValue(), theR1, theW1, theL1, theR2, theW2, theL2, + theRL, theWL, theLtransL, theLthinL, + theRR, theWR, theLtransR, theLthinR, + theRI, theWI, theLtransI, theLthinI, + !theHexMesh); + aFunction->SetValue(aResShape); + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient; + aSeq->Append(aShape); + + try { + if (theHexMesh) { + // Get the groups + if (!MakeGroups(aShape, TSHAPE_FILLET, theR1, theW1, theL1, theR2, theW2, theL2, + 0., 0., theRF, aSeq, gp_Trsf())) + return NULL; + } + + // Get internal group. + if (!MakeInternalGroup(aShape, theR1, theL1, theR2, theL2, theRL, theLtransL, + theRR, theLtransR, theRI, theLtransI, + aSeq, gp_Trsf())) { + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //Make a Python command + TCollection_AsciiString anEntry, aListRes("["); + // Iterate over the sequence aSeq + Standard_Integer aNbGroups = aSeq->Length(); + Standard_Integer i = 1; + for (; i <= aNbGroups; i++) { + Handle(Standard_Transient) anItem = aSeq->Value(i); + if (anItem.IsNull()) continue; + Handle(GEOM_Object) aGroup = Handle(GEOM_Object)::DownCast(anItem); + if (aGroup.IsNull()) continue; + //Make a Python command + TDF_Tool::Entry(aGroup->GetEntry(), anEntry); + aListRes += anEntry + ", "; + } + aListRes.Trunc(aListRes.Length() - 2); + + GEOM::TPythonDump pd (aFunction); + + pd << aListRes.ToCString() << "] = geompy.MakePipeTShapeFillet(" + << theR1 << ", " << theW1 << ", " << theL1 << ", " + << theR2 << ", " << theW2 << ", " << theL2 << ", " + << theRF << ", " << theHexMesh; + + // thickness reduction + if (isTRL) + pd << ", theRL=" << theRL << ", theWL=" << theWL + << ", theLtransL=" << theLtransL << ", theLthinL=" << theLthinL; + if (isTRR) + pd << ", theRR=" << theRR << ", theWR=" << theWR + << ", theLtransR=" << theLtransR << ", theLthinR=" << theLthinR; + if (isTRI) + pd << ", theRI=" << theRI << ", theWI=" << theWI + << ", theLtransI=" << theLtransI << ", theLthinI=" << theLthinI; + + pd << ")"; + + SetErrorCode(OK); + + return aSeq; +} + +//============================================================================= +/*! + * MakePipeTShapeFilletWithPosition + * \brief Create a T-shape object with specified caracteristics for the main and + * the incident pipes (radius, width, half-length). A fillet is created + * on the junction of the pipes. + * The extremities of the main pipe are located on junctions points P1 and P2. + * The extremity of the incident pipe is located on junction point P3. + * \param theR1 Internal radius of main pipe + * \param theW1 Width of main pipe + * \param theL1 Half-length of main pipe + * \param theR2 Internal radius of incident pipe (R2 < R1) + * \param theW2 Width of incident pipe (R2+W2 < R1+W1) + * \param theL2 Half-length of incident pipe + * \param theRF Radius of curvature of fillet + * \param theHexMesh Boolean indicating if shape is prepared for hex mesh + * \param theP1 1st junction point of main pipe + * \param theP2 2nd junction point of main pipe + * \param theP3 Junction point of incident pipe + * \return List of GEOM_Objects, containing the created shape and propagation groups. + */ +//============================================================================= +Handle(TColStd_HSequenceOfTransient) +GEOMImpl_IAdvancedOperations::MakePipeTShapeFilletWithPosition + (double theR1, double theW1, double theL1, + double theR2, double theW2, double theL2, + double theRL, double theWL, double theLtransL, double theLthinL, + double theRR, double theWR, double theLtransR, double theLthinR, + double theRI, double theWI, double theLtransI, double theLthinI, + double theRF, bool theHexMesh, + Handle(GEOM_Object) theP1, + Handle(GEOM_Object) theP2, + Handle(GEOM_Object) theP3) +{ + SetErrorCode(KO); + //Add a new object + Handle(GEOM_Object) aShape = GetEngine()->AddObject(GetDocID(), GEOM_TSHAPE); + //Add a new shape function with parameters + Handle(GEOM_Function) aFunction = aShape->AddFunction(GEOMImpl_PipeTShapeDriver::GetID(), TSHAPE_FILLET); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_PipeTShapeDriver::GetID()) return NULL; + + // Check new position + if (!CheckCompatiblePosition(theL1, theL2, theP1, theP2, theP3, 0.01)) { + return NULL; + } + + GEOMImpl_IPipeTShape aData(aFunction); + + aData.SetR1(theR1); + aData.SetW1(theW1); + aData.SetL1(theL1); + aData.SetR2(theR2); + aData.SetW2(theW2); + aData.SetL2(theL2); + aData.SetRF(theRF); + aData.SetHexMesh(theHexMesh); + + bool isTRL = (theRL + theWL + theLtransL + theLthinL) > Precision::Confusion(); + bool isTRR = (theRR + theWR + theLtransR + theLthinR) > Precision::Confusion(); + bool isTRI = (theRI + theWI + theLtransI + theLthinI) > Precision::Confusion(); + + //Compute the resulting value + try { +#if OCC_VERSION_LARGE > 0x06010000 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("TShape driver failed"); + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + // BEGIN of fillet + TopoDS_Shape aShapeShape = aShape->GetValue(); + TopTools_IndexedMapOfShape anEdgesIndices; + TopExp::MapShapes(aShapeShape, anEdgesIndices); + // Common edges on external cylinders + Handle(GEOM_Object) box_e; + if (theHexMesh) { + box_e = my3DPrimOperations->MakeBoxDXDYDZ(theR2+theW2, theR2+theW2, theR1+theW1); + } + else { + box_e = my3DPrimOperations->MakeBoxDXDYDZ(2*(theR2+theW2), 2*(theR2+theW2), theR1+theW1); + } + box_e->GetLastFunction()->SetDescription(""); + box_e = myTransformOperations->TranslateDXDYDZ(box_e, -(theR2+theW2), -(theR2+theW2), 0); + box_e->GetLastFunction()->SetDescription(""); + + Handle(TColStd_HSequenceOfInteger) edges_e = + myShapesOperations->GetShapesOnBoxIDs(box_e, aShape, TopAbs_EDGE, GEOMAlgo_ST_IN); + box_e->GetLastFunction()->SetDescription(""); + + if (edges_e.IsNull() || edges_e->Length() == 0) { + SetErrorCode("External edges not found"); + return NULL; + } + int nbEdgesInFillet = 0; + std::list theEdges; + for (int i=1; i<=edges_e->Length();i++) { + int edgeID = edges_e->Value(i); + TopoDS_Shape theEdge = anEdgesIndices.FindKey(edgeID); + TopExp_Explorer Ex(theEdge,TopAbs_VERTEX); + while (Ex.More()) { + gp_Pnt aPt = BRep_Tool::Pnt(TopoDS::Vertex(Ex.Current())); + if (Abs(aPt.Z() - (theR1+theW1)) <= Precision::Confusion()) { + nbEdgesInFillet ++; + theEdges.push_back(edgeID); + } + Ex.Next(); + } + if (theHexMesh && nbEdgesInFillet == 1) + break; + } + + Handle(GEOM_Object) aFillet; + try { + aFillet = myLocalOperations->MakeFilletEdges(aShape, theRF, theEdges); + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + if (aFillet.IsNull()) { + SetErrorCode("Fillet can not be computed on the given shape with the given parameters"); + return NULL; + } + aFillet->GetLastFunction()->SetDescription(""); + + TopoDS_Shape aFilletShape = aFillet->GetValue(); + aFunction->SetValue(aFilletShape); + // END of fillet + +// VSR: debug issues 0021568 and 0021550 (15/05/2012) - BEGIN (3) +// the following block, when enabled, leads to partitioning problems +#if 0 +// VSR: debug issues 0021568 and 0021550 (15/05/2012) - END (3) + // BEGIN: Limit tolerances (debug) + Handle(GEOM_Object) aCorr1 = myHealingOperations->LimitTolerance(aShape, 1e-07); + TopoDS_Shape aCorr1Shape = aCorr1->GetValue(); + aShape->GetLastFunction()->SetValue(aCorr1Shape); + aCorr1->GetLastFunction()->SetDescription(""); + // END: Limit tolerances (debug) +// VSR: debug issues 0021568 and 0021550 (15/05/2012) - BEGIN (4) +#endif +// VSR: debug issues 0021568 and 0021550 (15/05/2012) - END (4) + + if (theHexMesh) { + if (!MakePipeTShapePartition(aShape, theR1, theW1, theL1, theR2, theW2, theL2, 0, 0, theRF, false)) + return NULL; + if (!MakePipeTShapeMirrorAndGlue(aShape, theR1, theW1, theL1, theR2, theW2, theL2)) + return NULL; + } + + // Add thickness reduction elements + // at the three extremities: Left, Right and Incident + try { +#if OCC_VERSION_LARGE > 0x06010000 + OCC_CATCH_SIGNALS; +#endif + if (isTRL || isTRR || isTRI) { + TopoDS_Shape aResShape = + MakePipeTShapeThicknessReduction(aShape->GetValue(), theR1, theW1, theL1, theR2, theW2, theL2, + theRL, theWL, theLtransL, theLthinL, + theRR, theWR, theLtransR, theLthinR, + theRI, theWI, theLtransI, theLthinI, + !theHexMesh); + aFunction->SetValue(aResShape); + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + // Set Position + gp_Trsf aTrsf = GetPositionTrsf(theL1, theL2, theP1, theP2, theP3); + BRepBuilderAPI_Transform aTransformation (aShape->GetValue(), aTrsf, Standard_False); + TopoDS_Shape aTrsf_Shape = aTransformation.Shape(); + aFunction->SetValue(aTrsf_Shape); + + Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient; + aSeq->Append(aShape); + + try { + if (theHexMesh) { + // Get the groups + if (!MakeGroups(aShape, TSHAPE_FILLET, theR1, theW1, theL1, theR2, theW2, theL2, + 0., 0., theRF, aSeq, aTrsf)) + return NULL; + } + + // Get internal group. + if (!MakeInternalGroup(aShape, theR1, theL1, theR2, theL2, theRL, theLtransL, + theRR, theLtransR, theRI, theLtransI, + aSeq, aTrsf)) { + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //Make a Python command + TCollection_AsciiString anEntry, aListRes("["); + // Iterate over the sequence aSeq + Standard_Integer aNbGroups = aSeq->Length(); + Standard_Integer i = 1; + for (; i <= aNbGroups; i++) { + Handle(Standard_Transient) anItem = aSeq->Value(i); + if (anItem.IsNull()) continue; + Handle(GEOM_Object) aGroup = Handle(GEOM_Object)::DownCast(anItem); + if (aGroup.IsNull()) continue; + //Make a Python command + TDF_Tool::Entry(aGroup->GetEntry(), anEntry); + aListRes += anEntry + ", "; + } + aListRes.Trunc(aListRes.Length() - 2); + + GEOM::TPythonDump pd (aFunction); + + pd << aListRes.ToCString() << "] = geompy.MakePipeTShapeFillet(" + << theR1 << ", " << theW1 << ", " << theL1 << ", " + << theR2 << ", " << theW2 << ", " << theL2 << ", " + << theRF << ", " << theHexMesh << ", " + << theP1 << ", " << theP2 << ", " << theP3; + + // thickness reduction + if (isTRL) + pd << ", theRL=" << theRL << ", theWL=" << theWL + << ", theLtransL=" << theLtransL << ", theLthinL=" << theLthinL; + if (isTRR) + pd << ", theRR=" << theRR << ", theWR=" << theWR + << ", theLtransR=" << theLtransR << ", theLthinR=" << theLthinR; + if (isTRI) + pd << ", theRI=" << theRI << ", theWI=" << theWI + << ", theLtransI=" << theLtransI << ", theLthinI=" << theLthinI; + + pd << ")"; + + SetErrorCode(OK); + + return aSeq; +} + +//============================================================================= +/*! + * This function allows to create a disk already divided into blocks. It can be + * used to create divided pipes for later meshing in hexaedra. + * \param theR Radius of the disk + * \param theRatio Relative size of the central square diagonal against the disk diameter + * \param theOrientation Plane on which the disk will be built + * \param thePattern The division pattern of the disk (hexagon or square in the center) + * \return New GEOM_Object, containing the created shape. + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IAdvancedOperations::MakeDividedDisk (double theR, double theRatio, + int theOrientation, int thePattern) +{ + SetErrorCode(KO); + + if (theOrientation != 1 && + theOrientation != 2 && + theOrientation != 3) + { + SetErrorCode("theOrientation must be 1(=OXY), 2(=OYZ) or 3(=OZX)"); + return NULL; + } + //Add a new object + Handle(GEOM_Object) aShape = GetEngine()->AddObject(GetDocID(), GEOM_DIVIDEDDISK); + + //Add a new shape function with parameters + Handle(GEOM_Function) aFunction = aShape->AddFunction(GEOMImpl_DividedDiskDriver::GetID(), DIVIDEDDISK_R_RATIO); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_DividedDiskDriver::GetID()) return NULL; + + GEOMImpl_IDividedDisk aData (aFunction); + + aData.SetR(theR); + aData.SetRatio(theRatio); + aData.SetOrientation(theOrientation); + aData.SetType(thePattern); + + //Compute the resulting value + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("DividedDisk driver failed"); + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + std::string aPatternStr; + + switch(thePattern) + { + case 0: + aPatternStr = "GEOM.SQUARE"; + break; + case 1: + aPatternStr = "GEOM.HEXAGON"; + break; + } + + //Make a Python command + GEOM::TPythonDump(aFunction) << aShape << " = geompy.MakeDividedDisk(" << theR << ", " << theOrientation << ", " << aPatternStr.c_str() << ")"; + + SetErrorCode(OK); + + return aShape; +} + +//============================================================================= +/*! + * This function allows to create a disk already divided into blocks. It can be + * used to create divided pipes for later meshing in hexaedra. + * \param theR Radius of the disk + * \param theRatio Relative size of the central square diagonal against the disk diameter + * \return New GEOM_Object, containing the created shape. + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IAdvancedOperations::MakeDividedDiskPntVecR (Handle(GEOM_Object) thePnt, + Handle(GEOM_Object) theVec, + double theR, + double theRatio, + int thePattern) +{ + SetErrorCode(KO); + + //Add a new object + Handle(GEOM_Object) aShape = GetEngine()->AddObject(GetDocID(), GEOM_DIVIDEDDISK); + + //Add a new shape function with parameters + Handle(GEOM_Function) aFunction = aShape->AddFunction(GEOMImpl_DividedDiskDriver::GetID(), DIVIDEDDISK_R_VECTOR_PNT); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_DividedDiskDriver::GetID()) return NULL; + + GEOMImpl_IDividedDisk aData (aFunction); + + Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction(); + Handle(GEOM_Function) aRefVec = theVec->GetLastFunction(); + + if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL; + + aData.SetCenter(aRefPnt); + aData.SetVector(aRefVec); + + aData.SetR(theR); + aData.SetRatio(theRatio); + aData.SetType(thePattern); + + //Compute the resulting value + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("DividedDisk driver failed"); + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + std::string aPatternStr; + + switch(thePattern) + { + case 0: + aPatternStr = "GEOM.SQUARE"; + break; + case 1: + aPatternStr = "GEOM.HEXAGON"; + break; + } + + + //Make a Python command + GEOM::TPythonDump(aFunction) << aShape << " = geompy.MakeDividedDiskPntVecR(" << thePnt << ", " << theVec << ", " << theR << ", " << aPatternStr.c_str() << ")"; + + SetErrorCode(OK); + + return aShape; +} + +//============================================================================= +/*! + * Builds a cylinder prepared for hexa meshes + * \param theR Radius of the cylinder + * \param theH Height of the cylinder + * \return New GEOM_Object, containing the created shape. + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IAdvancedOperations::MakeDividedCylinder (double theR, + double theH, + int thePattern) +{ + SetErrorCode(KO); + + //Add a new object + Handle(GEOM_Object) aShape = GetEngine()->AddObject(GetDocID(), GEOM_DIVIDEDCYLINDER); + + Handle(GEOM_Object) aBaseShape = MakeDividedDisk(theR, 67.0, 1, thePattern); + aBaseShape->GetLastFunction()->SetDescription(""); // Erase dump of MakeDividedDisk + + aShape = my3DPrimOperations->MakePrismDXDYDZ(aBaseShape,0.0,0.0,theH, -1.0); + + Handle(GEOM_Function) aFunction = aShape->GetLastFunction(); + aFunction->SetDescription(""); // Erase dump of MakePrismDXDYDZ + aShape->SetType(GEOM_DIVIDEDCYLINDER); + + std::string aPatternStr; + + switch(thePattern) + { + case 0: + aPatternStr = "GEOM.SQUARE"; + break; + case 1: + aPatternStr = "GEOM.HEXAGON"; + break; + } + + //Make a Python command + GEOM::TPythonDump(aFunction) << aShape << " = geompy.MakeDividedCylinder(" << theR << ", " << theH << ", " << aPatternStr.c_str() << ")"; + + SetErrorCode(OK); + + return aShape; +} +//============================================================================= +/*! + * Create a smoothing surface from a set of points + * \param thelPoints list of points + * \return New GEOM_Object, containing the created shape. + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IAdvancedOperations::MakeSmoothingSurface (std::list thelPoints) +{ + SetErrorCode(KO); + + //Add a new object + Handle(GEOM_Object) aShape = GetEngine()->AddObject(GetDocID(), GEOM_SMOOTHINGSURFACE); + + //Add a new shape function with parameters + Handle(GEOM_Function) aFunction = aShape->AddFunction(GEOMImpl_SmoothingSurfaceDriver::GetID(), SMOOTHINGSURFACE_LPOINTS); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_SmoothingSurfaceDriver::GetID()) return NULL; + + GEOMImpl_ISmoothingSurface aData (aFunction); + + int aLen = thelPoints.size(); + aData.SetLength(aLen); + int ind = 1; + std::list::iterator it = thelPoints.begin(); + for (; it != thelPoints.end(); it++, ind++) { + Handle(GEOM_Function) aRefPnt = (*it)->GetLastFunction(); + if (aRefPnt.IsNull()) { + SetErrorCode("NULL point for bSplineFaceShape"); + return NULL; + } + aData.SetPoint(ind, aRefPnt); + } + + + //Compute the resulting value + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("SmoothingSurface driver failed"); + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //Make a Python command + GEOM::TPythonDump pd (aFunction); + pd << aShape << " = geompy.MakeSmoothingSurface(["; + it = thelPoints.begin(); + pd << (*it++); + while (it != thelPoints.end()) { + pd << ", " << (*it++); + } + pd << "])"; + + SetErrorCode(OK); + + return aShape; +} +/*@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@*/ diff --git a/src/AdvancedEngine/GEOMImpl_IAdvancedOperations.hxx b/src/AdvancedEngine/GEOMImpl_IAdvancedOperations.hxx new file mode 100644 index 000000000..2ee7edb2f --- /dev/null +++ b/src/AdvancedEngine/GEOMImpl_IAdvancedOperations.hxx @@ -0,0 +1,242 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : GEOMImpl_IAdvancedOperations.hxx +// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) + +#ifndef _GEOMImpl_IAdvancedOperations_HXX_ +#define _GEOMImpl_IAdvancedOperations_HXX_ + +#include +#include "GEOM_IOperations.hxx" +#include "GEOM_Engine.hxx" +#include "GEOM_Object.hxx" + +#include +#include + +class GEOMImpl_IBasicOperations; +class GEOMImpl_IBooleanOperations; +class GEOMImpl_IShapesOperations; +class GEOMImpl_ITransformOperations; +class GEOMImpl_IBlocksOperations; +class GEOMImpl_I3DPrimOperations; +class GEOMImpl_ILocalOperations; +class GEOMImpl_IHealingOperations; +class GEOMImpl_IGroupOperations; +class Handle_Geom_Surface; +class TopTools_ListOfShape; + +class GEOMImpl_IAdvancedOperations: public GEOM_IOperations { +private: + bool MakePipeTShapePartition(Handle(GEOM_Object) theShape, + double theR1, double theW1, double theL1, + double theR2, double theW2, double theL2, + double theH = 0, double theW = 0, + double theRF = 0, bool isNormal = true); + + bool MakePipeTShapeMirrorAndGlue(Handle(GEOM_Object) theShape, + double theR1, double theW1, double theL1, + double theR2, double theW2, double theL2); + + bool MakePipeTShapeThicknessReduction (Handle(GEOM_Object) theShape, + double theR1, double theW1, double theL1, + double theR2, double theW2, double theL2, + double theRL, double theWL, double theLtransL, double theLthinL, + double theRR, double theWR, double theLtransR, double theLthinR, + double theRI, double theWI, double theLtransI, double theLthinI); + + bool MakeGroups(Handle(GEOM_Object) theShape, int shapType, + double theR1, double theW1, double theL1, + double theR2, double theW2, double theL2, + double theH, double theW, double theRF, + Handle(TColStd_HSequenceOfTransient) theSeq, + gp_Trsf aTrsf); + + bool GetFacesOnSurf(const TopoDS_Shape &theShape, + const Handle_Geom_Surface& theSurface, + const Standard_Real theTolerance, + TopTools_ListOfShape &theFaces); + + TopoDS_Shape MakeConicalFace(const gp_Ax2 &theAxis, + const double theRadius, + const double theRadiusThin, + const double theHeight, + const gp_Trsf &theTrsf); + + bool MakeInternalGroup(const Handle(GEOM_Object) &theShape, + const double theR1, const double theLen1, + const double theR2, const double theLen2, + const double theRL, const double theTransLenL, + const double theRR, const double theTransLenR, + const double theRI, const double theTransLenI, + const Handle(TColStd_HSequenceOfTransient) &theSeq, + const gp_Trsf &theTrsf); + + gp_Trsf GetPositionTrsf(double theL1, double theL2, + Handle(GEOM_Object) P1 = 0, + Handle(GEOM_Object) P2 = 0, + Handle(GEOM_Object) P3 = 0); + + bool CheckCompatiblePosition(double& theL1, double& theL2, + Handle(GEOM_Object) theP1, + Handle(GEOM_Object) theP2, + Handle(GEOM_Object) theP3, + double theTolerance); + +private: + GEOMImpl_IBasicOperations* myBasicOperations; + GEOMImpl_IBooleanOperations* myBooleanOperations; + GEOMImpl_IShapesOperations* myShapesOperations; + GEOMImpl_ITransformOperations* myTransformOperations; + GEOMImpl_IBlocksOperations* myBlocksOperations; + GEOMImpl_I3DPrimOperations* my3DPrimOperations; + GEOMImpl_ILocalOperations* myLocalOperations; + GEOMImpl_IHealingOperations* myHealingOperations; + GEOMImpl_IGroupOperations* myGroupOperations; + +public: + + /*! + * \brief Add three thickness reductions at the open ends of the pipe T-Shape + * + * \param theShape - the pipe T-Shape + * \param r1 - the internal radius of main pipe + * \param w1 - the thickness of main pipe + * \param l1 - the half-length of main pipe + * \param r2 - the internal radius of incident pipe + * \param w2 - the thickness of incident pipe + * \param l2 - the half-length of main pipe + * \param r*, w*, ltrans* and lthin* - internal radius, thickness, length of transition part + * and length of thin part of left(L), right(R) and + * incident(I) thickness reduction correspondingly + * \param fuseReductions - boolean flag (use true to generate single solid, + * false to obtain parts, useful for hexameshing) + * \retval TopoDS_Shape - Resulting shape + */ + Standard_EXPORT static TopoDS_Shape MakePipeTShapeThicknessReduction + (TopoDS_Shape theShape, + double r1, double w1, double l1, + double r2, double w2, double l2, + double rL, double wL, double ltransL, double lthinL, + double rR, double wR, double ltransR, double lthinR, + double rI, double wI, double ltransI, double lthinI, + bool fuseReductions); + + /*! + * \brief Create one thickness reduction element + * + * This method is called three times from MakePipeTShapeThicknessReduction + * to create three thickness reductions (one per each open end of a pipe T-Shape) + * + * \param theAxes - the position + * \param R - the internal radius of main pipe + * \param W - the thickness of main pipe + * \param Rthin - the internal radius of thin part + * \param Wthin - the thickness of thin part + * \param Ltrans - the length of transition part + * \param Lthin - the length of thin part + * \param fuse - boolean flag (use true to generate single solid, + * false to obtain parts, useful for hexameshing) + * \retval TopoDS_Shape - Resulting shape + */ + Standard_EXPORT static TopoDS_Shape MakeThicknessReduction (gp_Ax2 theAxes, + const double R, const double W, + const double Rthin, const double Wthin, + const double Ltrans, const double Lthin, + bool fuse); + +public: + Standard_EXPORT GEOMImpl_IAdvancedOperations(GEOM_Engine* theEngine, int theDocID); + Standard_EXPORT ~GEOMImpl_IAdvancedOperations(); + + Standard_EXPORT Handle(TColStd_HSequenceOfTransient) + MakePipeTShape(double theR1, double theW1, double theL1, + double theR2, double theW2, double theL2, + double theRL, double theWL, double theLtransL, double theLthinL, + double theRR, double theWR, double theLtransR, double theLthinR, + double theRI, double theWI, double theLtransI, double theLthinI, + bool theHexMesh = true); + + Standard_EXPORT Handle(TColStd_HSequenceOfTransient) + MakePipeTShapeWithPosition(double theR1, double theW1, double theL1, + double theR2, double theW2, double theL2, + double theRL, double theWL, double theLtransL, double theLthinL, + double theRR, double theWR, double theLtransR, double theLthinR, + double theRI, double theWI, double theLtransI, double theLthinI, + bool theHexMesh = true, + Handle(GEOM_Object) P1 = 0, + Handle(GEOM_Object) P2 = 0, + Handle(GEOM_Object) P3 = 0); + + Standard_EXPORT Handle(TColStd_HSequenceOfTransient) + MakePipeTShapeChamfer(double theR1, double theW1, double theL1, + double theR2, double theW2, double theL2, + double theRL, double theWL, double theLtransL, double theLthinL, + double theRR, double theWR, double theLtransR, double theLthinR, + double theRI, double theWI, double theLtransI, double theLthinI, + double theH, double theW, + bool theHexMesh = true); + + Standard_EXPORT Handle(TColStd_HSequenceOfTransient) + MakePipeTShapeChamferWithPosition(double theR1, double theW1, double theL1, + double theR2, double theW2, double theL2, + double theH, double theW, + double theRL, double theWL, double theLtransL, double theLthinL, + double theRR, double theWR, double theLtransR, double theLthinR, + double theRI, double theWI, double theLtransI, double theLthinI, + bool theHexMesh = true, + Handle(GEOM_Object) P1 = 0, + Handle(GEOM_Object) P2 = 0, + Handle(GEOM_Object) P3 = 0); + + Standard_EXPORT Handle(TColStd_HSequenceOfTransient) + MakePipeTShapeFillet(double theR1, double theW1, double theL1, + double theR2, double theW2, double theL2, + double theRL, double theWL, double theLtransL, double theLthinL, + double theRR, double theWR, double theLtransR, double theLthinR, + double theRI, double theWI, double theLtransI, double theLthinI, + double theRF, bool theHexMesh = true); + + Standard_EXPORT Handle(TColStd_HSequenceOfTransient) + MakePipeTShapeFilletWithPosition(double theR1, double theW1, double theL1, + double theR2, double theW2, double theL2, + double theRL, double theWL, double theLtransL, double theLthinL, + double theRR, double theWR, double theLtransR, double theLthinR, + double theRI, double theWI, double theLtransI, double theLthinI, + double theRF, bool theHexMesh = true, + Handle(GEOM_Object) P1 = 0, + Handle(GEOM_Object) P2 = 0, + Handle(GEOM_Object) P3 = 0); + + Standard_EXPORT Handle(GEOM_Object) MakeDividedDisk (double theR, double theRatio, + int theOrientation, int thePattern); + Standard_EXPORT Handle(GEOM_Object) MakeDividedDiskPntVecR (Handle(GEOM_Object) thePnt, + Handle(GEOM_Object) theVec, + double theR, + double theRatio, + int thePattern); + + Standard_EXPORT Handle(GEOM_Object) MakeDividedCylinder (double theR, + double theH, + int thePattern); + + Standard_EXPORT Handle(GEOM_Object) MakeSmoothingSurface (std::list thelPoints); + /*@@ insert new functions before this line @@ do not remove this line @@*/ +}; +#endif diff --git a/src/AdvancedEngine/GEOMImpl_IDividedDisk.hxx b/src/AdvancedEngine/GEOMImpl_IDividedDisk.hxx new file mode 100644 index 000000000..3d2be4a4f --- /dev/null +++ b/src/AdvancedEngine/GEOMImpl_IDividedDisk.hxx @@ -0,0 +1,64 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef _GEOMImpl_IDividedDisk_HXX_ +#define _GEOMImpl_IDividedDisk_HXX_ + +#include "GEOM_Function.hxx" + +#define DIVIDEDDISK_ARG_R 1 +#define DIVIDEDDISK_ARG_RATIO 2 +#define DIVIDEDDISK_ARG_ORIENT 3 + +#define DIVIDEDDISK_ARG_CENTER 4 +#define DIVIDEDDISK_ARG_VECTOR 5 + +#define DIVIDEDDISK_ARG_TYPE 6 + +class GEOMImpl_IDividedDisk +{ +public: + GEOMImpl_IDividedDisk(Handle(GEOM_Function) theFunction): _func(theFunction) {} + + void SetR(double theR) { _func->SetReal(DIVIDEDDISK_ARG_R, theR); } + double GetR() { return _func->GetReal(DIVIDEDDISK_ARG_R); } + + void SetRatio(double theRatio) { _func->SetReal(DIVIDEDDISK_ARG_RATIO, theRatio); } + double GetRatio() { return _func->GetReal(DIVIDEDDISK_ARG_RATIO); } + + void SetOrientation(int theOrientation) { _func->SetInteger(DIVIDEDDISK_ARG_ORIENT, theOrientation); } + int GetOrientation() { return _func->GetInteger(DIVIDEDDISK_ARG_ORIENT); } + + void SetType(int theType) { _func->SetInteger(DIVIDEDDISK_ARG_TYPE, theType); } + int GetType() { return _func->GetInteger(DIVIDEDDISK_ARG_TYPE); } + + void SetCenter(Handle(GEOM_Function) theP) { _func->SetReference(DIVIDEDDISK_ARG_CENTER, theP); } + void SetVector(Handle(GEOM_Function) theV) { _func->SetReference(DIVIDEDDISK_ARG_VECTOR, theV); } + + Handle(GEOM_Function) GetCenter() { return _func->GetReference(DIVIDEDDISK_ARG_CENTER); } + Handle(GEOM_Function) GetVector() { return _func->GetReference(DIVIDEDDISK_ARG_VECTOR); } + +private: + Handle(GEOM_Function) _func; +}; + +#endif // _GEOMImpl_IDividedDisk_HXX_ diff --git a/src/AdvancedEngine/GEOMImpl_IPipeTShape.hxx b/src/AdvancedEngine/GEOMImpl_IPipeTShape.hxx new file mode 100644 index 000000000..8d9b60a5b --- /dev/null +++ b/src/AdvancedEngine/GEOMImpl_IPipeTShape.hxx @@ -0,0 +1,103 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef _GEOMImpl_IPipeTShape_HXX_ +#define _GEOMImpl_IPipeTShape_HXX_ + +#include "GEOM_Function.hxx" + +#include + +class GEOMImpl_IPipeTShape +{ +public: + GEOMImpl_IPipeTShape(Handle(GEOM_Function) theFunction): _func(theFunction) {} + + void SetR1(double theR1) { _func->SetReal(TSHAPE_ARG_R1, theR1); } + double GetR1() { return _func->GetReal(TSHAPE_ARG_R1); } + + void SetW1(double theW1) { _func->SetReal(TSHAPE_ARG_W1, theW1); } + double GetW1() { return _func->GetReal(TSHAPE_ARG_W1); } + + void SetL1(double theL1) { _func->SetReal(TSHAPE_ARG_L1, theL1); } + double GetL1() { return _func->GetReal(TSHAPE_ARG_L1); } + + void SetR2(double theR2) { _func->SetReal(TSHAPE_ARG_R2, theR2); } + double GetR2() { return _func->GetReal(TSHAPE_ARG_R2); } + + void SetW2(double theW2) { _func->SetReal(TSHAPE_ARG_W2, theW2); } + double GetW2() { return _func->GetReal(TSHAPE_ARG_W2); } + + void SetL2(double theL2) { _func->SetReal(TSHAPE_ARG_L2, theL2); } + double GetL2() { return _func->GetReal(TSHAPE_ARG_L2); } + + void SetH(double theH) { _func->SetReal(TSHAPE_ARG_H, theH); } + double GetH() { return _func->GetReal(TSHAPE_ARG_H); } + + void SetW(double theW) { _func->SetReal(TSHAPE_ARG_W, theW); } + double GetW() { return _func->GetReal(TSHAPE_ARG_W); } + + void SetRF(double theRF) { _func->SetReal(TSHAPE_ARG_RF, theRF); } + double GetRF() { return _func->GetReal(TSHAPE_ARG_RF); } + + void SetHexMesh(int theHexMesh) { _func->SetInteger(TSHAPE_ARG_HEXMESH, theHexMesh); } + int GetHexMesh() { return _func->GetInteger(TSHAPE_ARG_HEXMESH); } + + void SetP1(const Handle(GEOM_Function)& theP1){_func->SetReference(TSHAPE_ARG_P1, theP1); } + Handle(GEOM_Function) GetP1() { return _func->GetReference(TSHAPE_ARG_P1); } + + void SetP2(const Handle(GEOM_Function)& theP2){_func->SetReference(TSHAPE_ARG_P2, theP2); } + Handle(GEOM_Function) GetP2() { return _func->GetReference(TSHAPE_ARG_P2); } + + void SetP3(const Handle(GEOM_Function)& theP3){_func->SetReference(TSHAPE_ARG_P3, theP3); } + Handle(GEOM_Function) GetP3() { return _func->GetReference(TSHAPE_ARG_P3); } + +private: + enum { + // main pipe + TSHAPE_ARG_R1 = 1, + TSHAPE_ARG_W1 = 2, + TSHAPE_ARG_L1 = 3, + + // incident pipe + TSHAPE_ARG_R2 = 4, + TSHAPE_ARG_W2 = 5, + TSHAPE_ARG_L2 = 6, + + // chamfer + TSHAPE_ARG_H = 7, + TSHAPE_ARG_W = 8, + + // fillet + TSHAPE_ARG_RF = 9, + + // partition + TSHAPE_ARG_HEXMESH = 10, + + // junction points + TSHAPE_ARG_P1 = 11, + TSHAPE_ARG_P2 = 12, + TSHAPE_ARG_P3 = 13 + }; + +private: + Handle(GEOM_Function) _func; +}; + +#endif // _GEOMImpl_IPipeTShape_HXX_ diff --git a/src/AdvancedEngine/GEOMImpl_ISmoothingSurface.hxx b/src/AdvancedEngine/GEOMImpl_ISmoothingSurface.hxx new file mode 100644 index 000000000..2ca3ac1de --- /dev/null +++ b/src/AdvancedEngine/GEOMImpl_ISmoothingSurface.hxx @@ -0,0 +1,45 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com + +#ifndef _GEOMImpl_ISmoothingSurface_HXX_ +#define _GEOMImpl_ISmoothingSurface_HXX_ + +#include "GEOM_Function.hxx" + +#define SMOOTHINGSURFACE_ARG_LENG 1 +#define SMOOTHINGSURFACE_ARG_LAST 2 + +class GEOMImpl_ISmoothingSurface +{ +public: + GEOMImpl_ISmoothingSurface(Handle(GEOM_Function) theFunction): _func(theFunction) {} + + void SetLength(int theLen) { _func->SetInteger(SMOOTHINGSURFACE_ARG_LENG, theLen); } + int GetLength() { return _func->GetInteger(SMOOTHINGSURFACE_ARG_LENG); } + + void SetPoint(int theId, Handle(GEOM_Function) theP) { _func->SetReference(SMOOTHINGSURFACE_ARG_LAST + theId, theP); } + Handle(GEOM_Function) GetPoint(int theId) { return _func->GetReference(SMOOTHINGSURFACE_ARG_LAST + theId); } + +private: + Handle(GEOM_Function) _func; +}; + +#endif // _GEOMImpl_ISmoothingSurface_HXX_ diff --git a/src/AdvancedEngine/GEOMImpl_PipeTShapeDriver.cxx b/src/AdvancedEngine/GEOMImpl_PipeTShapeDriver.cxx new file mode 100644 index 000000000..3641ee7fc --- /dev/null +++ b/src/AdvancedEngine/GEOMImpl_PipeTShapeDriver.cxx @@ -0,0 +1,677 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com + +#include + +#include +#include +#include +#include + +#include +#include + +#include + +#include +#include +#include + +#include +#include + +// Partition includes +#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 required header files here @@// + +#include "AdvancedEngine_Types.hxx" + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& GEOMImpl_PipeTShapeDriver::GetID() +{ + static Standard_GUID aGUID("1C3A0F3F-729D-4E83-8232-78E74FC5637C"); + return aGUID; +} + +//======================================================================= +//function : GEOMImpl_PipeTShapeDriver +//purpose : +//======================================================================= +GEOMImpl_PipeTShapeDriver::GEOMImpl_PipeTShapeDriver() +{ +} + +//======================================================================= +//function : getShapesOnBoxIDs + /*! + * \brief Find IDs of sub-shapes complying with given status about surface + * \param theBox - the box to check state of sub-shapes against + * \param theShape - the shape to explore + * \param theShapeType - type of sub-shape of theShape + * \param theState - required state + * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes + */ +//======================================================================= +Handle(TColStd_HSequenceOfInteger) +GEOMImpl_PipeTShapeDriver::GetShapesOnBoxIDs(const TopoDS_Shape& aBox, + const TopoDS_Shape& aShape, + const Standard_Integer theShapeType, + GEOMAlgo_State theState) const +{ + Handle(TColStd_HSequenceOfInteger) aSeqOfIDs; + + // Check presence of triangulation, build if need + if (!GEOMUtils::CheckTriangulation(aShape)) { + StdFail_NotDone::Raise("Cannot build triangulation on the shape"); + return aSeqOfIDs; + } + + // Call algo + GEOMAlgo_FinderShapeOn2 aFinder; + Standard_Real aTol = 0.0001; // default value + + Handle(GEOMAlgo_ClsfBox) aClsfBox = new GEOMAlgo_ClsfBox; + aClsfBox->SetBox(aBox); + + aFinder.SetShape(aShape); + aFinder.SetTolerance(aTol); + aFinder.SetClsf(aClsfBox); + aFinder.SetShapeType( (TopAbs_ShapeEnum)theShapeType ); + aFinder.SetState(theState); + aFinder.Perform(); + + // Interprete results + Standard_Integer iErr = aFinder.ErrorStatus(); + // the detailed description of error codes is in GEOMAlgo_FinderShapeOn1.cxx + if (iErr) { + TCollection_AsciiString aMsg (" iErr : "); + aMsg += TCollection_AsciiString(iErr); + StdFail_NotDone::Raise(aMsg.ToCString()); + return aSeqOfIDs; + } + + + const TopTools_ListOfShape& listSS = aFinder.Shapes(); // the result + + if (listSS.Extent() < 1) { + StdFail_NotDone::Raise(NOT_FOUND_ANY); // NPAL18017 + return aSeqOfIDs; + } + + // Fill sequence of object IDs + aSeqOfIDs = new TColStd_HSequenceOfInteger; + + TopTools_IndexedMapOfShape anIndices; + TopExp::MapShapes(aShape, anIndices); + + TopTools_ListIteratorOfListOfShape itSub (listSS); + for (int index = 1; itSub.More(); itSub.Next(), ++index) { + int id = anIndices.FindIndex(itSub.Value()); +// std::cerr << "Shape with ID " << id << " found" << std::endl; + aSeqOfIDs->Append(id); + } + + return aSeqOfIDs; +} + +//======================================================================= +//function : GetShapesOnSurfaceIDs + /*! + * \brief Find IDs of sub-shapes complying with given status about surface + * \param theSurface - the surface to check state of sub-shapes against + * \param theShape - the shape to explore + * \param theShapeType - type of sub-shape of theShape + * \param theState - required state + * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes + */ +//======================================================================= +Handle(TColStd_HSequenceOfInteger) + GEOMImpl_PipeTShapeDriver::GetShapesOnSurfaceIDs(const Handle(Geom_Surface)& theSurface, + const TopoDS_Shape& theShape, + TopAbs_ShapeEnum theShapeType, + GEOMAlgo_State theState) const +{ + Handle(TColStd_HSequenceOfInteger) aSeqOfIDs; + + // Check presence of triangulation, build if need + if (!GEOMUtils::CheckTriangulation(theShape)) { + StdFail_NotDone::Raise("Cannot build triangulation on the shape"); + return aSeqOfIDs; + } + + // Call algo + GEOMAlgo_FinderShapeOn1 aFinder; + Standard_Real aTol = 1e-6; + + aFinder.SetShape(theShape); + aFinder.SetTolerance(aTol); + aFinder.SetSurface(theSurface); + aFinder.SetShapeType(theShapeType); + aFinder.SetState(theState); + + // Sets the minimal number of inner points for the faces that do not have own + // inner points at all (for e.g. rectangular planar faces have just 2 triangles). + // Default value=3 + aFinder.SetNbPntsMin(3); + // Sets the maximal number of inner points for edges or faces. + // It is usefull for the cases when this number is very big (e.g =2000) to improve + // the performance. If this value =0, all inner points will be taken into account. + // Default value=0 + aFinder.SetNbPntsMax(0); + + aFinder.Perform(); + + // Interprete results + Standard_Integer iErr = aFinder.ErrorStatus(); + // the detailed description of error codes is in GEOMAlgo_FinderShapeOn1.cxx + if (iErr) { +// MESSAGE(" iErr : " << iErr); + TCollection_AsciiString aMsg (" iErr : "); + aMsg += TCollection_AsciiString(iErr); + StdFail_NotDone::Raise(aMsg.ToCString()); + return aSeqOfIDs; + } +// Standard_Integer iWrn = aFinder.WarningStatus(); + // the detailed description of warning codes is in GEOMAlgo_FinderShapeOn1.cxx +// if (iWrn) { +// MESSAGE(" *** iWrn : " << iWrn); +// } + + const TopTools_ListOfShape& listSS = aFinder.Shapes(); // the result + + if (listSS.Extent() < 1) { + //StdFail_NotDone::Raise("Not a single sub-shape of the requested type found on the given surface"); + StdFail_NotDone::Raise(NOT_FOUND_ANY); // NPAL18017 + return aSeqOfIDs; + } + + // Fill sequence of object IDs + aSeqOfIDs = new TColStd_HSequenceOfInteger; + + TopTools_IndexedMapOfShape anIndices; + TopExp::MapShapes(theShape, anIndices); + + TopTools_ListIteratorOfListOfShape itSub (listSS); + for (int index = 1; itSub.More(); itSub.Next(), ++index) { + int id = anIndices.FindIndex(itSub.Value()); + aSeqOfIDs->Append(id); + } + + return aSeqOfIDs; +} + +//======================================================================= +//function : GetCommonShapesOnCylinders +//purpose : return the common shapes between 2 cylindrical surfaces +// along OX and OZ +//======================================================================= +void GEOMImpl_PipeTShapeDriver::GetCommonShapesOnCylinders(const TopoDS_Shape& theShape, + TopAbs_ShapeEnum theShapeType, + double r1, + double r2, + Handle(TopTools_HSequenceOfShape)& commonShapes) const +{ + gp_Pnt aP0 (0, 0, 0); + gp_Vec aVX = gp::DX(), aVZ = gp::DZ(); + gp_Ax3 anAxis1 (aP0, aVX, aVZ), anAxis2 (aP0, aVZ, aVX); + + TopTools_IndexedMapOfShape aMapOfShapes; + aMapOfShapes.Clear(); + TopExp::MapShapes(theShape, aMapOfShapes); + + commonShapes->Clear(); + + int myID; + bool found = false; + + // Create a cylinder surface + Handle(Geom_Surface) aC1Ext = new Geom_CylindricalSurface(anAxis1, r1); + if ( aC1Ext.IsNull() ) + StdFail_NotDone::Raise("Couldn't build main cylindrical surface"); + // Find object IDs + Handle(TColStd_HSequenceOfInteger) aSeqExt1 = GetShapesOnSurfaceIDs( aC1Ext, theShape, theShapeType, GEOMAlgo_ST_ON ); + // Create a cylinder surface + Handle(Geom_Surface) aC2Ext = new Geom_CylindricalSurface(anAxis2, r2); + if ( aC2Ext.IsNull() ) + StdFail_NotDone::Raise("Couldn't build incident cylindrical surface"); + // Find object IDs + Handle(TColStd_HSequenceOfInteger) aSeqExt2 = GetShapesOnSurfaceIDs( aC2Ext, theShape, theShapeType, GEOMAlgo_ST_ON ); + // # Recherche (dans le quart de Te) de l'arete d'intersection des 2 cylindres + // # Search in theShape for common shape of type theShapeType on the intersection of 2 pipes + found = false; + for (int i=1; i<=aSeqExt2->Length();i++) { +// std::cerr << "aSeqExt2->Value(i): " << aSeqExt2->Value(i) << std::endl; + for (int j=1; j<=aSeqExt1->Length();j++) { +// std::cerr << "aSeqExt1->Value(j): " << aSeqExt1->Value(j) << std::endl; + if (aSeqExt1->Value(j) == aSeqExt2->Value(i)) { + myID = aSeqExt1->Value(j); + commonShapes->Append(aMapOfShapes.FindKey(myID)); + found = true; + } + } + } + if (!found) + StdFail_NotDone::Raise("Common shapes couldn't be found"); +} + +//======================================================================= +//function : MakePipeTShape +//purpose : +//======================================================================= +TopoDS_Shape GEOMImpl_PipeTShapeDriver::MakePipeTShape (const double r1, const double w1, const double l1, + const double r2, const double w2, const double l2) const +{ + double r1Ext = r1 + w1; + double r2Ext = r2 + w2; + + gp_Pnt aP0 (0, 0, 0); + gp_Pnt aP1 (-l1, 0, 0); + gp_Vec aVX = gp::DX(), aVY = gp::DY(), aVZ = gp::DZ(); + gp_Ax2 anAxes1 (aP1, aVX, aVZ); + gp_Ax2 anAxes2 (aP0, aVZ, aVX); + + // Build the initial pipes + BRepPrimAPI_MakeCylinder C1Int (anAxes1, r1, Abs(2 * l1)); + BRepPrimAPI_MakeCylinder C1Ext (anAxes1, r1Ext, Abs(2 * l1)); + BRepPrimAPI_MakeCylinder C2Int (anAxes2, r2, Abs(l2)); + BRepPrimAPI_MakeCylinder C2Ext (anAxes2, r2Ext, Abs(l2)); + C1Int.Build(); + C1Ext.Build(); + C2Int.Build(); + C2Ext.Build(); + if (!C1Int.IsDone() || !C1Ext.IsDone() || !C2Int.IsDone() || !C2Ext.IsDone()) { + StdFail_NotDone::Raise("Cannot build cylinders"); + } + + // Fuse the 2 pipes + BRepAlgoAPI_Fuse fuse1 (C1Ext.Shape(), C2Ext.Shape()); + if (!fuse1.IsDone()) { + StdFail_NotDone::Raise("Cannot fuse cylinders"); + } + + // Remove small radius main pipe + BRepAlgoAPI_Cut cut1 (fuse1.Shape(), C1Int.Shape()); + if (!cut1.IsDone()) { + StdFail_NotDone::Raise("Coudn't cut cylinders"); + } + + // Remove small radius incident pipe => Te + BRepAlgoAPI_Cut Te (cut1.Shape(), C2Int.Shape()); + if (!Te.IsDone()) { + StdFail_NotDone::Raise("Coudn't cut cylinders"); + } + + return Te.Shape(); +} + +//======================================================================= +//function : MakeQuarterPipeTShape +//purpose : +//======================================================================= +TopoDS_Shape GEOMImpl_PipeTShapeDriver::MakeQuarterPipeTShape (const double r1, const double w1, const double l1, + const double r2, const double w2, const double l2) const +{ + TopoDS_Shape Te = MakePipeTShape(r1, w1, l1, r2, w2, l2); + if (Te.IsNull()) + StdFail_NotDone::Raise("Couldn't build Pipe TShape"); + + // Get a quarter of shape => Te2 + double r1Ext = r1 + w1; + BRepPrimAPI_MakeBox box1 (gp_Pnt(0, -2*r1Ext, -2*r1Ext), gp_Pnt( Abs(2 * l1), 2*r1Ext, Abs(2*l2))); + BRepPrimAPI_MakeBox box2 (gp_Pnt(0, 2*r1Ext, -2*r1Ext), gp_Pnt(-Abs(2 * l1), 0, Abs(2*l2))); + box1.Build(); + box2.Build(); + if (!box1.IsDone() || !box2.IsDone()) { + StdFail_NotDone::Raise("Couldn't build boxes"); + } + BRepAlgoAPI_Cut cut3 (Te, box1.Shape()); + if (!cut3.IsDone()) { + StdFail_NotDone::Raise("Couldn't cut Pipe Tshape with box"); + } + BRepAlgoAPI_Cut Te4 (cut3.Shape(), box2.Shape()); + if (!Te4.IsDone()) { + StdFail_NotDone::Raise("Couldn't cut Pipe Tshape with box"); + } + + return Te4.Shape(); +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_PipeTShapeDriver::Execute (TFunction_Logbook& log) const +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); + + GEOMImpl_IPipeTShape aData (aFunction); + Standard_Integer aType = aFunction->GetType(); + + TopoDS_Shape aShape, Te4, Te4Part; + //TopoDS_Edge arete_intersect_int; + //Handle(TopTools_HSequenceOfShape) edges_e = new TopTools_HSequenceOfShape; + Handle(TColStd_HSequenceOfInteger) edges_e; + //Handle(TopTools_HSequenceOfShape) edges_i = new TopTools_HSequenceOfShape; + //gp_Pnt aP0 (0, 0, 0); + //gp_Vec aVX = gp::DX(), aVY = gp::DY(), aVZ = gp::DZ(); + bool hexMesh = (bool) aData.GetHexMesh(); + + // Useful values + //double aSize = 2*(aData.GetL1() + aData.GetL2()); + double epsilon = Precision::Approximation(); + double aR1Ext = aData.GetR1() + aData.GetW1(); + double aR2Ext = aData.GetR2() + aData.GetW2(); + + if (aData.GetR2() > aData.GetR1() + epsilon) { + StdFail_NotDone::Raise("TShape cannot be computed if R2 > R1"); + } + + if (aR2Ext > aR1Ext + epsilon) { + StdFail_NotDone::Raise("TShape cannot be computed if R2+W2 > R1+W1"); + } + + // external radius are equal + if (fabs(aR2Ext - aR1Ext) < epsilon) { + if (aType == TSHAPE_CHAMFER) + StdFail_NotDone::Raise("TShape with chamfer cannot be computed if R2+W2 = R1+W1"); + if (aType == TSHAPE_FILLET) + StdFail_NotDone::Raise("TShape with fillet cannot be computed if R2+W2 = R1+W1"); + // internal radius are different => not possible + if (fabs(aData.GetR2() - aData.GetR1()) > epsilon) { + StdFail_NotDone::Raise("TShape cannot be computed if R2+W2 = R1+W1 and R2 != R1"); + } + } + + if (aR1Ext >= aData.GetL2() + epsilon) { + StdFail_NotDone::Raise("TShape cannot be computed if R1+W1 >= L2"); + } + if (aR2Ext >= aData.GetL1() + epsilon) { + StdFail_NotDone::Raise("TShape cannot be computed if R2+W2 >= L1"); + } + + if (aType == TSHAPE_CHAMFER) { + if (aData.GetH() >= (aData.GetL2() - aR1Ext + epsilon)) { + StdFail_NotDone::Raise("TShape cannot be computed: height of chamfer is too high"); + } + + if (aData.GetW() >= (aData.GetL1() - aR2Ext + epsilon)) + StdFail_NotDone::Raise("TShape cannot be computed: width of chamfer is too high"); + } + + if (aType == TSHAPE_FILLET) { + if (aData.GetRF() >= (aData.GetL2() - aR1Ext + epsilon) || + aData.GetRF() >= (aData.GetL1() - aR2Ext + epsilon)) + StdFail_NotDone::Raise("TShape cannot be computed: radius of fillet is too high"); + } + + if (hexMesh) { + // Create a quarter of a basic T-Shape pipe + //std::cerr << "Create a quarter of a basic T-Shape pipe" << std::endl; + Te4 = MakeQuarterPipeTShape(aData.GetR1(), aData.GetW1(), aData.GetL1(), + aData.GetR2(), aData.GetW2(), aData.GetL2()); + } + else { + // No need to cut pipe t-shape + //std::cerr << "Create a basic T-Shape pipe" << std::endl; + Te4 = MakePipeTShape(aData.GetR1(), aData.GetW1(), aData.GetL1(), + aData.GetR2(), aData.GetW2(), aData.GetL2()); + } + aShape = Te4; +/* + if (aType == TSHAPE_BASIC) { + aShape = Te4; +// aShape = MakeQuarterPipeTShape(aData.GetR1(), aData.GetW1(), aData.GetL1(), +// aData.GetR2(), aData.GetW2(), aData.GetL2()); + } + else if (aType == TSHAPE_CHAMFER) { + // TShape with chamfer +// BRep_Builder BB; +// TopoDS_Compound CC; +// BB.MakeCompound(CC); + // Create chamfer on the edges edges_e + BRepFilletAPI_MakeChamfer chamfer (Te4); + TopTools_IndexedMapOfShape anEdgesIndices; + TopExp::MapShapes(Te4, anEdgesIndices); + + TopoDS_Shape theBox; + if (hexMesh) { + BRepPrimAPI_MakeBox aBox (gp_Pnt(0,0,0),gp_Pnt(-aR2Ext, -aR2Ext, aR1Ext)); + aBox.Build(); + if (!aBox.IsDone()) { + StdFail_NotDone::Raise("Couldn't build box"); + } + theBox = aBox.Shape(); + } + else { + BRepPrimAPI_MakeBox aBox (gp_Pnt(aR2Ext,aR2Ext,0),gp_Pnt(-aR2Ext, -aR2Ext, aR1Ext)); + aBox.Build(); + if (!aBox.IsDone()) { + StdFail_NotDone::Raise("Couldn't build box"); + } + theBox = aBox.Shape(); + } + Handle(TColStd_HSequenceOfInteger) edges_e = new TColStd_HSequenceOfInteger; + edges_e = GetShapesOnBoxIDs(theBox, Te4, TopAbs_EDGE, GEOMAlgo_ST_IN); + if (edges_e.IsNull() || edges_e->Length() == 0) { + StdFail_NotDone::Raise("Common edges not found"); + } + + TopTools_IndexedDataMapOfShapeListOfShape M; + GEOMImpl_Block6Explorer::MapShapesAndAncestors(Te4, TopAbs_EDGE, TopAbs_FACE, M); +// std::cerr << "Number of IDs: " << edges_e->Length() << std::endl; + int nbEdgesInChamfer = 0; + for (int i=1;i<=edges_e->Length();i++) { +// std::cerr << "Get Edge with ID #" << i << std::endl; + int theId = edges_e->Value(i); +// std::cerr << "ID #" << i << "= " << theId << std::endl; +// std::cerr << "Search for edge in shape" << std::endl; + TopoDS_Edge theEdge = TopoDS::Edge(anEdgesIndices.FindKey(theId)); +// std::cerr << "Found" << std::endl; +// std::cerr << "Keep only edges with a vertex on (x, x, re1)" << std::endl; + TopExp_Explorer ExVertices; + for (ExVertices.Init(theEdge,TopAbs_VERTEX); ExVertices.More(); ExVertices.Next()) { + gp_Pnt aPt = BRep_Tool::Pnt(TopoDS::Vertex(ExVertices.Current())); + if (aPt.Z() - aR1Ext <= epsilon) { +// std::cerr << "aPt.Z() = aR1Ext => keep this edge" << std::endl; + nbEdgesInChamfer ++; + const TopTools_ListOfShape& aFL = M.FindFromKey(theEdge); + TopoDS_Face F = TopoDS::Face( aFL.First() ); + if (hexMesh) + chamfer.Add(aData.GetH(), aData.GetW(), theEdge, F); + else + chamfer.Add(aData.GetW(), aData.GetH(), theEdge, F); + break; + } + } +// std::cerr << "Test if hexMesh: "; + if (hexMesh && nbEdgesInChamfer == 1) { +// std::cerr << "Yes => stop after 1 edge" << std::endl; + break; + } +// std::cerr << "No => continue for other edges" << std::endl; + // BB.Add(CC, edges_e->Value(i)); + // const TopTools_ListOfShape& aFL = M.FindFromKey(TopoDS::Edge(edges_e->Value(i))); + // chamfer.Add(aData.GetW(), aData.GetH(), TopoDS::Edge(edges_e->Value(i)), F); + } +// std::cerr << "Build chamfer with " << nbEdgesInChamfer << " edges" << std::endl; +// } + chamfer.Build(); + if (!chamfer.IsDone()) { + StdFail_NotDone::Raise("Chamfer can not be computed on the given shape with the given parameters"); + } + +// BB.Add(CC, chamfer.Shape()); + +// aShape = CC; + aShape = chamfer.Shape(); + } + else if (aType == TSHAPE_FILLET) { + // TShape with fillet + // Create fillet on the edge arete_intersect_ext + BRepFilletAPI_MakeFillet fill (Te4); + + TopTools_IndexedMapOfShape anIndices; + TopExp::MapShapes(Te4, anIndices); + + TopoDS_Shape theBox; + if (hexMesh) { + BRepPrimAPI_MakeBox aBox (gp_Pnt(0,0,0),gp_Pnt(-aR2Ext, -aR2Ext, aR1Ext)); + aBox.Build(); + if (!aBox.IsDone()) { + StdFail_NotDone::Raise("Couldn't build box"); + } + theBox = aBox.Shape(); + } + else { + BRepPrimAPI_MakeBox aBox (gp_Pnt(aR2Ext,aR2Ext,0),gp_Pnt(-aR2Ext, -aR2Ext, aR1Ext)); + aBox.Build(); + if (!aBox.IsDone()) { + StdFail_NotDone::Raise("Couldn't build box"); + } + theBox = aBox.Shape(); + } + Handle(TColStd_HSequenceOfInteger) edges_e = new TColStd_HSequenceOfInteger; + edges_e = GetShapesOnBoxIDs(theBox, Te4, TopAbs_EDGE, GEOMAlgo_ST_IN); + if (edges_e.IsNull() || edges_e->Length() == 0) { + StdFail_NotDone::Raise("Common edges not found"); + } + +// fill.Add(TopoDS::Edge(edges_e->Value(1))); +// if (!hexMesh) { + for (int i=1;i<=edges_e->Length();i++) { + if (hexMesh && (i > 1)) + break; + TopoDS_Edge theEdge = TopoDS::Edge(anIndices.FindKey(edges_e->Value(i))); + fill.Add(theEdge); +// fill.Add(TopoDS::Edge(edges_e->Value(i))); + } +// } + fill.SetRadius(aData.GetRF(), 1, 1); + fill.Build(); + if (!fill.IsDone()) { + StdFail_NotDone::Raise("Fillet can't be computed on the given shape with the given radius"); + } + + aShape = fill.Shape(); + } + else { + // other construction modes here + } +*/ + if (aShape.IsNull()) return 0; + + aFunction->SetValue(aShape); + + log.SetTouched(Label()); + + return 1; +} + +//================================================================================ +/*! + * \brief Returns a name of creation operation and names and values of creation parameters + */ +//================================================================================ + +bool GEOMImpl_PipeTShapeDriver:: +GetCreationInformation(std::string& theOperationName, + std::vector& theParams) +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) function = GEOM_Function::GetFunction(Label()); + + GEOMImpl_IPipeTShape aCI( function ); + Standard_Integer aType = function->GetType(); + + theOperationName = "PIPETSHAPE"; + + switch ( aType ) { + case TSHAPE_BASIC: + AddParam( theParams, "Main radius", aCI.GetR1() ); + AddParam( theParams, "Main width", aCI.GetW1() ); + AddParam( theParams, "Main half-length", aCI.GetL1() ); + AddParam( theParams, "Incident pipe radius", aCI.GetR2() ); + AddParam( theParams, "Incident pipe width", aCI.GetW2() ); + AddParam( theParams, "Incident pipe half-length", aCI.GetL2() ); + AddParam( theParams, "For hex mesh", aCI.GetHexMesh() ); + break; + case TSHAPE_CHAMFER: + AddParam( theParams, "Main radius", aCI.GetR1() ); + AddParam( theParams, "Main width", aCI.GetW1() ); + AddParam( theParams, "Main half-length", aCI.GetL1() ); + AddParam( theParams, "Incident pipe radius", aCI.GetR2() ); + AddParam( theParams, "Incident pipe width", aCI.GetW2() ); + AddParam( theParams, "Incident pipe half-length", aCI.GetL2() ); + AddParam( theParams, "Chamfer height", aCI.GetH() ); + AddParam( theParams, "Chamfer width", aCI.GetW() ); + AddParam( theParams, "For hex mesh", aCI.GetHexMesh() ); + break; + case TSHAPE_FILLET: + AddParam( theParams, "Main radius", aCI.GetR1() ); + AddParam( theParams, "Main width", aCI.GetW1() ); + AddParam( theParams, "Main half-length", aCI.GetL1() ); + AddParam( theParams, "Incident pipe radius", aCI.GetR2() ); + AddParam( theParams, "Incident pipe width", aCI.GetW2() ); + AddParam( theParams, "Incident pipe half-length", aCI.GetL2() ); + AddParam( theParams, "Fillet radius", aCI.GetRF() ); + AddParam( theParams, "For hex mesh", aCI.GetHexMesh() ); + break; + default: + return false; + } + + return true; +} + +IMPLEMENT_STANDARD_HANDLE (GEOMImpl_PipeTShapeDriver,GEOM_BaseDriver); +IMPLEMENT_STANDARD_RTTIEXT (GEOMImpl_PipeTShapeDriver,GEOM_BaseDriver); diff --git a/src/AdvancedEngine/GEOMImpl_PipeTShapeDriver.hxx b/src/AdvancedEngine/GEOMImpl_PipeTShapeDriver.hxx new file mode 100644 index 000000000..39396262c --- /dev/null +++ b/src/AdvancedEngine/GEOMImpl_PipeTShapeDriver.hxx @@ -0,0 +1,134 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef _GEOMImpl_PipeTShapeDriver_HXX +#define _GEOMImpl_PipeTShapeDriver_HXX + +#include + +#include "GEOMAlgo_State.hxx" + +#include +#include +#include +#include +#include +#include + +#include + +class Handle_Standard_Type; +class GEOMImpl_PipeTShapeDriver; + + + +#include "GEOM_BaseDriver.hxx" + +DEFINE_STANDARD_HANDLE( GEOMImpl_PipeTShapeDriver, GEOM_BaseDriver ); + +class GEOMImpl_PipeTShapeDriver : public GEOM_BaseDriver { +public: + // Methods PUBLIC + // + Standard_EXPORT GEOMImpl_PipeTShapeDriver(); + Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const; + Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {} + Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const + { + return Standard_True; + } + Standard_EXPORT static const Standard_GUID& GetID(); + Standard_EXPORT ~GEOMImpl_PipeTShapeDriver() {}; + + Standard_EXPORT virtual + bool GetCreationInformation(std::string& theOperationName, + std::vector& params); + // Type management + // +DEFINE_STANDARD_RTTI( GEOMImpl_PipeTShapeDriver ) + +private: + + /*! + * \brief Create a T-Shape based on pipes + * \param r1 - the internal radius of main pipe + * \param w1 - the thickness of main pipe + * \param l1 - the half-length of main pipe + * \param r2 - the internal radius of incident pipe + * \param w2 - the thickness of incident pipe + * \param l2 - the half-length of main pipe + * \retval TopoDS_Shape - Resulting shape + */ + TopoDS_Shape MakePipeTShape(double r1, double w1, double l1, + double r2, double w2, double l2) const; + + /*! + * \brief Create a quarter of a T-Shape based on pipes + * \param r1 - the internal radius of main pipe + * \param w1 - the thickness of main pipe + * \param l1 - the half-length of main pipe + * \param r2 - the internal radius of incident pipe + * \param w2 - the thickness of incident pipe + * \param l2 - the half-length of main pipe + * \retval TopoDS_Shape - Resulting shape + */ + TopoDS_Shape MakeQuarterPipeTShape(double r1, double w1, double l1, + double r2, double w2, double l2) const; + + /*! + * \brief Find IDs of sub-shapes complying with given status about surface + * \param theSurface - the surface to check state of sub-shapes against + * \param theShape - the shape to explore + * \param theShapeType - type of sub-shape of theShape + * \param theState - required state + * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes + */ + Handle(TColStd_HSequenceOfInteger) + GetShapesOnSurfaceIDs(const Handle(Geom_Surface)& theSurface, + const TopoDS_Shape& theShape, + TopAbs_ShapeEnum theShapeType, + GEOMAlgo_State theState) const; + + /*! + * \brief Find IDs of sub-shapes complying with given status about surface + * \param theBox - the box to check state of sub-shapes against + * \param theShape - the shape to explore + * \param theShapeType - type of sub-shape of theShape + * \param theState - required state + * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes + */ + Handle(TColStd_HSequenceOfInteger) + GetShapesOnBoxIDs(const TopoDS_Shape& aBox, + const TopoDS_Shape& aShape, + const Standard_Integer theShapeType, + GEOMAlgo_State theState) const; + + //======================================================================= + //function : getCommonShapesOnCylinders + //purpose : return the common edge between 2 cylindrical surfaces + // along OX and OZ + //======================================================================= + void GetCommonShapesOnCylinders(const TopoDS_Shape& theShape, + TopAbs_ShapeEnum theShapeType, + double r, double r2, + Handle(TopTools_HSequenceOfShape)& commonShapes) const; + +}; + +#endif // _GEOMImpl_PipeTShapeDriver_HXX diff --git a/src/AdvancedEngine/GEOMImpl_SmoothingSurfaceDriver.cxx b/src/AdvancedEngine/GEOMImpl_SmoothingSurfaceDriver.cxx new file mode 100644 index 000000000..2f4d80558 --- /dev/null +++ b/src/AdvancedEngine/GEOMImpl_SmoothingSurfaceDriver.cxx @@ -0,0 +1,232 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com + +#include + +#include "AdvancedEngine_Types.hxx" + +#include +#include +#include +#include + +#include +#include + +//@@ include required header files here @@// +#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 +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& GEOMImpl_SmoothingSurfaceDriver::GetID() +{ + static Standard_GUID aGUID("1C3A0F30-729D-4E83-8232-78E74FC5637C"); + return aGUID; +} + +//======================================================================= +//function : GEOMImpl_SmoothingSurfaceDriver +//purpose : +//======================================================================= +GEOMImpl_SmoothingSurfaceDriver::GEOMImpl_SmoothingSurfaceDriver() +{ +} + +//======================================================================= +//function : MakeSmoothingSurfaceUnClosed +//purpose : +//======================================================================= +TopoDS_Shape GEOMImpl_SmoothingSurfaceDriver::MakeSmoothingSurfaceUnClosed(Handle_TColgp_HArray1OfPnt myListOfPoints) const +{ + TopoDS_Face aInitShape; + + // Create an average Plane + //Handle(TColgp_HArray1OfPnt) HAP = new TColgp_HArray1OfPnt(1,myListOfPoints.Length()) + GeomPlate_BuildAveragePlane gpbap(myListOfPoints,myListOfPoints->Length(),Precision::Confusion(),1,1); + Handle(Geom_Plane) plane(gpbap.Plane()); + Standard_Real Umin, Umax, Vmin, Vmax; + gpbap.MinMaxBox(Umin,Umax,Vmin,Vmax); + // cout << "Vals : " << Umin << ", " << Umax << ", " << Vmin << ", " << Vmax << endl; + BRepBuilderAPI_MakeFace mf(plane,Umin,Umax,Vmin,Vmax,Precision::Confusion()); + aInitShape = mf.Face(); + //return aInitShape; + + GeomPlate_BuildPlateSurface aBuilder(3,10); + // ** Initialization of surface + Handle(BRepAdaptor_HSurface) HSI = new BRepAdaptor_HSurface(); + HSI->ChangeSurface().Initialize(aInitShape); + aBuilder.LoadInitSurface( BRep_Tool::Surface(HSI->ChangeSurface().Face())); + + Standard_Integer j, j1, j2; + // cout << "Init surface" << endl; + j1 = myListOfPoints->Lower(); + j2 = myListOfPoints->Upper(); + for (j=j1; j<=j2 ; j++) + { + gp_Pnt aPnt = myListOfPoints->Value(j); + Handle(GeomPlate_PointConstraint) PCont = new GeomPlate_PointConstraint(aPnt,0); + aBuilder.Add(PCont); + } + // cout << "avant Perform surface" << endl; + aBuilder.Perform(); + // cout << "Perform surface" << endl; + + // A ce niveau : surface algo + Handle(GeomPlate_Surface) gpPlate = aBuilder.Surface(); + + Standard_Integer nbcarreau=2; + Standard_Integer degmax=8; + Standard_Real seuil; + seuil = Max(0.0001,10*aBuilder.G0Error()); + GeomPlate_MakeApprox Mapp(gpPlate,0.0001,nbcarreau,degmax,seuil); + // cout << "Approx surface" << endl; + + Handle (Geom_Surface) Surf (Mapp.Surface()); + + aBuilder.Surface()->Bounds( Umin, Umax, Vmin, Vmax); + + BRepBuilderAPI_MakeFace MF(Surf,Umin, Umax, Vmin, Vmax, Precision::Confusion()); + TopoDS_Shape aShape = MF.Shape(); + + return aShape; +} + + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_SmoothingSurfaceDriver::Execute(TFunction_Logbook& log) const +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); + if (aFunction.IsNull()) return 0; + + Standard_Integer aType = aFunction->GetType(); + + if (aType != SMOOTHINGSURFACE_LPOINTS) return 0; + // cout << "Youhou : " << aType << endl; + + GEOMImpl_ISmoothingSurface aData (aFunction); + + Standard_Integer nbPoints = aData.GetLength(); + + Handle(TColgp_HArray1OfPnt) anArrayofPnt = new TColgp_HArray1OfPnt(1,nbPoints); + for (int ind=1;ind<=nbPoints;ind++) + { + Handle(GEOM_Function) aPoint = aData.GetPoint(ind); + TopoDS_Shape aShapePnt = aPoint->GetValue(); + TopoDS_Vertex dsPoint; + dsPoint = TopoDS::Vertex( aShapePnt ); + gp_Pnt aPnt = BRep_Tool::Pnt( dsPoint ); + anArrayofPnt->SetValue(ind,aPnt); + } + + TopoDS_Shape aShape; + aShape = GEOMImpl_SmoothingSurfaceDriver::MakeSmoothingSurfaceUnClosed(anArrayofPnt); + + if (aShape.IsNull()) return 0; + + aFunction->SetValue(aShape); + + log.SetTouched(Label()); + + return 1; +} + +//================================================================================ +/*! + * \brief Returns a name of creation operation and names and values of creation parameters + */ +//================================================================================ + +bool GEOMImpl_SmoothingSurfaceDriver:: +GetCreationInformation(std::string& theOperationName, + std::vector& theParams) +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) function = GEOM_Function::GetFunction(Label()); + + GEOMImpl_ISmoothingSurface aCI( function ); + Standard_Integer aType = function->GetType(); + + theOperationName = "SMOOTHINGSURFACE"; + + switch ( aType ) { + case SMOOTHINGSURFACE_LPOINTS: + AddParam( theParams, "Points" ); + if ( aCI.GetLength() > 1 ) + theParams[0] << aCI.GetLength() << " points: "; + for ( int i = 1, nb = aCI.GetLength(); i <= nb; ++i ) + theParams[0] << aCI.GetPoint( i ) << " "; + break; + default: + return false; + } + + return true; +} + +IMPLEMENT_STANDARD_HANDLE (GEOMImpl_SmoothingSurfaceDriver,GEOM_BaseDriver); +IMPLEMENT_STANDARD_RTTIEXT (GEOMImpl_SmoothingSurfaceDriver,GEOM_BaseDriver); diff --git a/src/AdvancedEngine/GEOMImpl_SmoothingSurfaceDriver.hxx b/src/AdvancedEngine/GEOMImpl_SmoothingSurfaceDriver.hxx new file mode 100644 index 000000000..3559fcc45 --- /dev/null +++ b/src/AdvancedEngine/GEOMImpl_SmoothingSurfaceDriver.hxx @@ -0,0 +1,71 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com + +#ifndef _GEOMImpl_SmoothingSurfaceDriver_HXX +#define _GEOMImpl_SmoothingSurfaceDriver_HXX + +#ifndef _TFunction_Driver_HeaderFile +#include +#endif +#ifndef _TFunction_Logbook_HeaderFile +#include +#endif +#ifndef _Standard_CString_HeaderFile +#include +#endif +#include +#include + +class Handle_Standard_Type; +class GEOMImpl_SmoothingSurfaceDriver; + + + +#include "GEOM_BaseDriver.hxx" + +DEFINE_STANDARD_HANDLE( GEOMImpl_SmoothingSurfaceDriver, GEOM_BaseDriver ); + +class GEOMImpl_SmoothingSurfaceDriver : public GEOM_BaseDriver { +public: + // Methods PUBLIC + // + Standard_EXPORT GEOMImpl_SmoothingSurfaceDriver(); + Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const; + Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {} + Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const + { + return Standard_True; + } + Standard_EXPORT static const Standard_GUID& GetID(); + Standard_EXPORT ~GEOMImpl_SmoothingSurfaceDriver() {}; + + Standard_EXPORT virtual + bool GetCreationInformation(std::string& theOperationName, + std::vector& params); + // Type management + // +DEFINE_STANDARD_RTTI( GEOMImpl_SmoothingSurfaceDriver ) + +private: + TopoDS_Shape MakeSmoothingSurfaceUnClosed(Handle_TColgp_HArray1OfPnt myListOfPoints) const; +}; + +#endif // _GEOMImpl_SmoothingSurfaceDriver_HXX diff --git a/src/AdvancedEngine/GEOM_AdvancedEngine.hxx b/src/AdvancedEngine/GEOM_AdvancedEngine.hxx new file mode 100755 index 000000000..ec1522503 --- /dev/null +++ b/src/AdvancedEngine/GEOM_AdvancedEngine.hxx @@ -0,0 +1,43 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com + +#ifndef _GEOM_ADVANCEDENGINE_HXX_ +#define _GEOM_ADVANCEDENGINE_HXX_ + +#ifdef WNT + #if defined ADVANCEDENGINE_EXPORTS || defined AdvancedEngine_EXPORTS + #if defined WIN32 + #define ADVANCEDENGINE_EXPORT __declspec( dllexport ) + #else + #define ADVANCEDENGINE_EXPORT + #endif + #else + #if defined WIN32 + #define ADVANCEDENGINE_EXPORT __declspec( dllimport ) + #else + #define ADVANCEDENGINE_EXPORT + #endif + #endif +#else + #define ADVANCEDENGINE_EXPORT +#endif + +#endif diff --git a/src/AdvancedEngine/GEOM_IAdvancedOperations_i.cc b/src/AdvancedEngine/GEOM_IAdvancedOperations_i.cc new file mode 100644 index 000000000..1fe516222 --- /dev/null +++ b/src/AdvancedEngine/GEOM_IAdvancedOperations_i.cc @@ -0,0 +1,785 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// File : GEOM_IAdvancedOperations.cc +// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) + +#include + +#include "GEOM_IAdvancedOperations_i.hh" + +#include +#include +#include + +#include "GEOM_Engine.hxx" +#include "GEOM_Object.hxx" + +//============================================================================= +/*! + * constructor: + */ +//============================================================================= +GEOM_IAdvancedOperations_i::GEOM_IAdvancedOperations_i(PortableServer::POA_ptr thePOA, GEOM::GEOM_Gen_ptr theEngine, ::GEOMImpl_IAdvancedOperations* theImpl) +:GEOM_IOperations_i(thePOA, theEngine, theImpl) +{ + MESSAGE("GEOM_IAdvancedOperations_i::GEOM_IAdvancedOperations_i"); +} + +//============================================================================= +/*! + * destructor + */ +//============================================================================= +GEOM_IAdvancedOperations_i::~GEOM_IAdvancedOperations_i() +{ + MESSAGE("GEOM_IAdvancedOperations_i::~GEOM_IAdvancedOperations_i"); +} + +//============================================================================= +/*! + * MakePipeTShape + * Create a T-shape object with specified caracteristics for the main and + * the incident pipes (radius, width, half-length). + * Center of the shape is (0,0,0). The main plane of the T-shape is XOY. + * \param theR1 Internal radius of main pipe + * \param theW1 Width of main pipe + * \param theL1 Half-length of main pipe + * \param theR2 Internal radius of incident pipe (R2 < R1) + * \param theW2 Width of incident pipe (R2+W2 < R1+W1) + * \param theL2 Half-length of incident pipe + * \param theHexMesh Boolean indicating if shape is prepared for hex mesh + * \return List of GEOM_Objects, containing the created shape and propagation groups. + */ +//============================================================================= +GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShape + (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, + CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, + CORBA::Boolean theHexMesh) +{ + GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Create the TShape + Handle(TColStd_HSequenceOfTransient) aHSeq = + GetOperations()->MakePipeTShape(theR1, theW1, theL1, theR2, theW2, theL2, + 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., + theHexMesh); + if (!GetOperations()->IsDone() || aHSeq.IsNull()) + return aSeq._retn(); + + Standard_Integer aLength = aHSeq->Length(); + aSeq->length(aLength); + for (Standard_Integer i = 1; i <= aLength; i++) + aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i))); + + return aSeq._retn(); +} + +//============================================================================= +/*! + * MakePipeTShapeWithPosition + * Create a T-shape object with specified caracteristics for the main and + * the incident pipes (radius, width, half-length). + * The extremities of the main pipe are located on junctions points P1 and P2. + * The extremity of the incident pipe is located on junction point P3. + * \param theR1 Internal radius of main pipe + * \param theW1 Width of main pipe + * \param theL1 Half-length of main pipe + * \param theR2 Internal radius of incident pipe (R2 < R1) + * \param theW2 Width of incident pipe (R2+W2 < R1+W1) + * \param theL2 Half-length of incident pipe + * \param theHexMesh Boolean indicating if shape is prepared for hex mesh + * \param theP1 1st junction point of main pipe + * \param theP2 2nd junction point of main pipe + * \param theP3 Junction point of incident pipe + * \return List of GEOM_Objects, containing the created shape and propagation groups. + */ +//============================================================================= +GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeWithPosition + (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, + CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, + CORBA::Boolean theHexMesh, + GEOM::GEOM_Object_ptr theP1, GEOM::GEOM_Object_ptr theP2, GEOM::GEOM_Object_ptr theP3) +{ + GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Get the reference vertices + Handle(GEOM_Object) aP1 = GetObjectImpl(theP1); + Handle(GEOM_Object) aP2 = GetObjectImpl(theP2); + Handle(GEOM_Object) aP3 = GetObjectImpl(theP3); + if (aP1.IsNull() || aP2.IsNull() || aP3.IsNull())return aSeq._retn(); + + //Create the TShape + Handle(TColStd_HSequenceOfTransient) aHSeq = + GetOperations()->MakePipeTShapeWithPosition(theR1, theW1, theL1, theR2, theW2, theL2, + 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., + theHexMesh, aP1, aP2, aP3); + if (!GetOperations()->IsDone() || aHSeq.IsNull()) + return aSeq._retn(); + + Standard_Integer aLength = aHSeq->Length(); + aSeq->length(aLength); + for (Standard_Integer i = 1; i <= aLength; i++) + aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i))); + + return aSeq._retn(); +} + +//============================================================================= +/*! + * MakePipeTShapeChamfer + * Create a T-shape object with specified caracteristics for the main and + * the incident pipes (radius, width, half-length). A chamfer is created + * on the junction of the pipes. + * Center of the shape is (0,0,0). The main plane of the T-shape is XOY. + * \param theR1 Internal radius of main pipe + * \param theW1 Width of main pipe + * \param theL1 Half-length of main pipe + * \param theR2 Internal radius of incident pipe (R2 < R1) + * \param theW2 Width of incident pipe (R2+W2 < R1+W1) + * \param theL2 Half-length of incident pipe + * \param theH Height of chamfer. + * \param theW Width of chamfer. + * \param theHexMesh Boolean indicating if shape is prepared for hex mesh + * \return List of GEOM_Objects, containing the created shape and propagation groups. + */ +//============================================================================= +GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeChamfer + (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, + CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, + CORBA::Double theH, CORBA::Double theW, CORBA::Boolean theHexMesh) +{ + GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Create the TShape + Handle(TColStd_HSequenceOfTransient) aHSeq = + GetOperations()->MakePipeTShapeChamfer(theR1, theW1, theL1, theR2, theW2, theL2, + 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., + theH, theW, theHexMesh); + if (!GetOperations()->IsDone() || aHSeq.IsNull()) + return aSeq._retn(); + + Standard_Integer aLength = aHSeq->Length(); + aSeq->length(aLength); + for (Standard_Integer i = 1; i <= aLength; i++) + aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i))); + + return aSeq._retn(); +} + +//============================================================================= +/*! + * MakePipeTShapeChamferWithPosition + * Create a T-shape object with specified caracteristics for the main and + * the incident pipes (radius, width, half-length). A chamfer is created + * on the junction of the pipes. + * The extremities of the main pipe are located on junctions points P1 and P2. + * The extremity of the incident pipe is located on junction point P3. + * \param theR1 Internal radius of main pipe + * \param theW1 Width of main pipe + * \param theL1 Half-length of main pipe + * \param theR2 Internal radius of incident pipe (R2 < R1) + * \param theW2 Width of incident pipe (R2+W2 < R1+W1) + * \param theL2 Half-length of incident pipe + * \param theH Height of the chamfer. + * \param theW Width of the chamfer. + * \param theHexMesh Boolean indicating if shape is prepared for hex mesh + * \param theP1 1st junction point of main pipe + * \param theP2 2nd junction point of main pipe + * \param theP3 Junction point of incident pipe + * \return List of GEOM_Objects, containing the created shape and propagation groups. + */ +//============================================================================= +GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeChamferWithPosition + (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, + CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, + CORBA::Double theH, CORBA::Double theW, CORBA::Boolean theHexMesh, + GEOM::GEOM_Object_ptr theP1, GEOM::GEOM_Object_ptr theP2, GEOM::GEOM_Object_ptr theP3) +{ + GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Get the reference vertices + Handle(GEOM_Object) aP1 = GetObjectImpl(theP1); + Handle(GEOM_Object) aP2 = GetObjectImpl(theP2); + Handle(GEOM_Object) aP3 = GetObjectImpl(theP3); + + //Create the TShape + Handle(TColStd_HSequenceOfTransient) aHSeq = + GetOperations()->MakePipeTShapeChamferWithPosition(theR1, theW1, theL1, theR2, theW2, theL2, + 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., + theH, theW, theHexMesh, aP1, aP2, aP3); + if (!GetOperations()->IsDone() || aHSeq.IsNull()) + return aSeq._retn(); + + Standard_Integer aLength = aHSeq->Length(); + aSeq->length(aLength); + for (Standard_Integer i = 1; i <= aLength; i++) + aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i))); + + return aSeq._retn(); +} + +//============================================================================= +/*! + * MakePipeTShapeFillet + * Create a T-shape object with specified caracteristics for the main and + * the incident pipes (radius, width, half-length). A fillet is created + * on the junction of the pipes. + * Center of the shape is (0,0,0). The main plane of the T-shape is XOY. + * \param theR1 Internal radius of main pipe + * \param theW1 Width of main pipe + * \param theL1 Half-length of main pipe + * \param theR2 Internal radius of incident pipe (R2 < R1) + * \param theW2 Width of incident pipe (R2+W2 < R1+W1) + * \param theL2 Half-length of incident pipe + * \param theRF Radius of curvature of fillet. + * \param theHexMesh Boolean indicating if shape is prepared for hex mesh + * \return List of GEOM_Objects, containing the created shape and propagation groups. + */ +//============================================================================= +GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeFillet + (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, + CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, + CORBA::Double theRF, CORBA::Boolean theHexMesh) +{ + GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Create the TShape + Handle(TColStd_HSequenceOfTransient) aHSeq = + GetOperations()->MakePipeTShapeFillet(theR1, theW1, theL1, theR2, theW2, theL2, + 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., + theRF, theHexMesh); + if (!GetOperations()->IsDone() || aHSeq.IsNull()) + return aSeq._retn(); + + Standard_Integer aLength = aHSeq->Length(); + aSeq->length(aLength); + for (Standard_Integer i = 1; i <= aLength; i++) + aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i))); + + return aSeq._retn(); +} + +//============================================================================= +/*! + * MakePipeTShapeFilletWithPosition + * Create a T-shape object with specified caracteristics for the main and + * the incident pipes (radius, width, half-length). A fillet is created + * on the junction of the pipes. + * The extremities of the main pipe are located on junctions points P1 and P2. + * The extremity of the incident pipe is located on junction point P3. + * \param theR1 Internal radius of main pipe + * \param theW1 Width of main pipe + * \param theL1 Half-length of main pipe + * \param theR2 Internal radius of incident pipe (R2 < R1) + * \param theW2 Width of incident pipe (R2+W2 < R1+W1) + * \param theL2 Half-length of incident pipe + * \param theRF Radius of curvature of fillet + * \param theHexMesh Boolean indicating if shape is prepared for hex mesh + * \param theP1 1st junction point of main pipe + * \param theP2 2nd junction point of main pipe + * \param theP3 Junction point of incident pipe + * \return List of GEOM_Objects, containing the created shape and propagation groups. + */ +//============================================================================= +GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeFilletWithPosition + (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, + CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, + CORBA::Double theRF, CORBA::Boolean theHexMesh, + GEOM::GEOM_Object_ptr theP1, GEOM::GEOM_Object_ptr theP2, GEOM::GEOM_Object_ptr theP3) +{ + GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Get the reference vertices + Handle(GEOM_Object) aP1 = GetObjectImpl(theP1); + Handle(GEOM_Object) aP2 = GetObjectImpl(theP2); + Handle(GEOM_Object) aP3 = GetObjectImpl(theP3); + + //Create the TShape + Handle(TColStd_HSequenceOfTransient) aHSeq = + GetOperations()->MakePipeTShapeFilletWithPosition(theR1, theW1, theL1, theR2, theW2, theL2, + 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., + theRF, theHexMesh, aP1, aP2, aP3); + if (!GetOperations()->IsDone() || aHSeq.IsNull()) + return aSeq._retn(); + + Standard_Integer aLength = aHSeq->Length(); + aSeq->length(aLength); + for (Standard_Integer i = 1; i <= aLength; i++) + aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i))); + + return aSeq._retn(); +} + +//============================================================================= +/*! + * MakePipeTShapeTR + * Create a T-shape object with specified caracteristics for the main and + * the incident pipes (radius, width, half-length). + * Center of the shape is (0,0,0). The main plane of the T-shape is XOY. + * \param theR1 Internal radius of main pipe + * \param theW1 Width of main pipe + * \param theL1 Half-length of main pipe + * \param theR2 Internal radius of incident pipe (R2 < R1) + * \param theW2 Width of incident pipe (R2+W2 < R1+W1) + * \param theL2 Half-length of incident pipe + * \param theHexMesh Boolean indicating if shape is prepared for hex mesh + * \return List of GEOM_Objects, containing the created shape and propagation groups. + */ +//============================================================================= +GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeTR + (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, + CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, + CORBA::Double theRL, CORBA::Double theWL, CORBA::Double theLtransL, CORBA::Double theLthinL, + CORBA::Double theRR, CORBA::Double theWR, CORBA::Double theLtransR, CORBA::Double theLthinR, + CORBA::Double theRI, CORBA::Double theWI, CORBA::Double theLtransI, CORBA::Double theLthinI, + CORBA::Boolean theHexMesh) +{ + GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Create the TShape + Handle(TColStd_HSequenceOfTransient) aHSeq = + GetOperations()->MakePipeTShape(theR1, theW1, theL1, theR2, theW2, theL2, + theRL, theWL, theLtransL, theLthinL, + theRR, theWR, theLtransR, theLthinR, + theRI, theWI, theLtransI, theLthinI, + theHexMesh); + if (!GetOperations()->IsDone() || aHSeq.IsNull()) + return aSeq._retn(); + + Standard_Integer aLength = aHSeq->Length(); + aSeq->length(aLength); + for (Standard_Integer i = 1; i <= aLength; i++) + aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i))); + + return aSeq._retn(); +} + +//============================================================================= +/*! + * MakePipeTShapeTRWithPosition + * Create a T-shape object with specified caracteristics for the main and + * the incident pipes (radius, width, half-length). + * The extremities of the main pipe are located on junctions points P1 and P2. + * The extremity of the incident pipe is located on junction point P3. + * \param theR1 Internal radius of main pipe + * \param theW1 Width of main pipe + * \param theL1 Half-length of main pipe + * \param theR2 Internal radius of incident pipe (R2 < R1) + * \param theW2 Width of incident pipe (R2+W2 < R1+W1) + * \param theL2 Half-length of incident pipe + * \param theHexMesh Boolean indicating if shape is prepared for hex mesh + * \param theP1 1st junction point of main pipe + * \param theP2 2nd junction point of main pipe + * \param theP3 Junction point of incident pipe + * \return List of GEOM_Objects, containing the created shape and propagation groups. + */ +//============================================================================= +GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeTRWithPosition + (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, + CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, + CORBA::Double theRL, CORBA::Double theWL, CORBA::Double theLtransL, CORBA::Double theLthinL, + CORBA::Double theRR, CORBA::Double theWR, CORBA::Double theLtransR, CORBA::Double theLthinR, + CORBA::Double theRI, CORBA::Double theWI, CORBA::Double theLtransI, CORBA::Double theLthinI, + CORBA::Boolean theHexMesh, + GEOM::GEOM_Object_ptr theP1, GEOM::GEOM_Object_ptr theP2, GEOM::GEOM_Object_ptr theP3) +{ + GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Get the reference vertices + Handle(GEOM_Object) aP1 = GetObjectImpl(theP1); + Handle(GEOM_Object) aP2 = GetObjectImpl(theP2); + Handle(GEOM_Object) aP3 = GetObjectImpl(theP3); + if (aP1.IsNull() || aP2.IsNull() || aP3.IsNull()) return aSeq._retn(); + + //Create the TShape + Handle(TColStd_HSequenceOfTransient) aHSeq = + GetOperations()->MakePipeTShapeWithPosition(theR1, theW1, theL1, theR2, theW2, theL2, + theRL, theWL, theLtransL, theLthinL, + theRR, theWR, theLtransR, theLthinR, + theRI, theWI, theLtransI, theLthinI, + theHexMesh, aP1, aP2, aP3); + if (!GetOperations()->IsDone() || aHSeq.IsNull()) + return aSeq._retn(); + + Standard_Integer aLength = aHSeq->Length(); + aSeq->length(aLength); + for (Standard_Integer i = 1; i <= aLength; i++) + aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i))); + + return aSeq._retn(); +} + +//============================================================================= +/*! + * MakePipeTShapeTRChamfer + * Create a T-shape object with specified caracteristics for the main and + * the incident pipes (radius, width, half-length). A chamfer is created + * on the junction of the pipes. + * Center of the shape is (0,0,0). The main plane of the T-shape is XOY. + * \param theR1 Internal radius of main pipe + * \param theW1 Width of main pipe + * \param theL1 Half-length of main pipe + * \param theR2 Internal radius of incident pipe (R2 < R1) + * \param theW2 Width of incident pipe (R2+W2 < R1+W1) + * \param theL2 Half-length of incident pipe + * \param theH Height of chamfer. + * \param theW Width of chamfer. + * \param theHexMesh Boolean indicating if shape is prepared for hex mesh + * \return List of GEOM_Objects, containing the created shape and propagation groups. + */ +//============================================================================= +GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeTRChamfer + (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, + CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, + CORBA::Double theRL, CORBA::Double theWL, CORBA::Double theLtransL, CORBA::Double theLthinL, + CORBA::Double theRR, CORBA::Double theWR, CORBA::Double theLtransR, CORBA::Double theLthinR, + CORBA::Double theRI, CORBA::Double theWI, CORBA::Double theLtransI, CORBA::Double theLthinI, + CORBA::Double theH, CORBA::Double theW, CORBA::Boolean theHexMesh) +{ + GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Create the TShape + Handle(TColStd_HSequenceOfTransient) aHSeq = + GetOperations()->MakePipeTShapeChamfer(theR1, theW1, theL1, theR2, theW2, theL2, + theRL, theWL, theLtransL, theLthinL, + theRR, theWR, theLtransR, theLthinR, + theRI, theWI, theLtransI, theLthinI, + theH, theW, theHexMesh); + if (!GetOperations()->IsDone() || aHSeq.IsNull()) + return aSeq._retn(); + + Standard_Integer aLength = aHSeq->Length(); + aSeq->length(aLength); + for (Standard_Integer i = 1; i <= aLength; i++) + aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i))); + + return aSeq._retn(); +} + +//============================================================================= +/*! + * MakePipeTShapeTRChamferWithPosition + * Create a T-shape object with specified caracteristics for the main and + * the incident pipes (radius, width, half-length). A chamfer is created + * on the junction of the pipes. + * The extremities of the main pipe are located on junctions points P1 and P2. + * The extremity of the incident pipe is located on junction point P3. + * \param theR1 Internal radius of main pipe + * \param theW1 Width of main pipe + * \param theL1 Half-length of main pipe + * \param theR2 Internal radius of incident pipe (R2 < R1) + * \param theW2 Width of incident pipe (R2+W2 < R1+W1) + * \param theL2 Half-length of incident pipe + * \param theH Height of the chamfer. + * \param theW Width of the chamfer. + * \param theHexMesh Boolean indicating if shape is prepared for hex mesh + * \param theP1 1st junction point of main pipe + * \param theP2 2nd junction point of main pipe + * \param theP3 Junction point of incident pipe + * \return List of GEOM_Objects, containing the created shape and propagation groups. + */ +//============================================================================= +GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeTRChamferWithPosition + (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, + CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, + CORBA::Double theRL, CORBA::Double theWL, CORBA::Double theLtransL, CORBA::Double theLthinL, + CORBA::Double theRR, CORBA::Double theWR, CORBA::Double theLtransR, CORBA::Double theLthinR, + CORBA::Double theRI, CORBA::Double theWI, CORBA::Double theLtransI, CORBA::Double theLthinI, + CORBA::Double theH, CORBA::Double theW, CORBA::Boolean theHexMesh, + GEOM::GEOM_Object_ptr theP1, GEOM::GEOM_Object_ptr theP2, GEOM::GEOM_Object_ptr theP3) +{ + GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Get the reference vertices + Handle(GEOM_Object) aP1 = GetObjectImpl(theP1); + Handle(GEOM_Object) aP2 = GetObjectImpl(theP2); + Handle(GEOM_Object) aP3 = GetObjectImpl(theP3); + + //Create the TShape + Handle(TColStd_HSequenceOfTransient) aHSeq = + GetOperations()->MakePipeTShapeChamferWithPosition(theR1, theW1, theL1, theR2, theW2, theL2, + theRL, theWL, theLtransL, theLthinL, + theRR, theWR, theLtransR, theLthinR, + theRI, theWI, theLtransI, theLthinI, + theH, theW, theHexMesh, aP1, aP2, aP3); + if (!GetOperations()->IsDone() || aHSeq.IsNull()) + return aSeq._retn(); + + Standard_Integer aLength = aHSeq->Length(); + aSeq->length(aLength); + for (Standard_Integer i = 1; i <= aLength; i++) + aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i))); + + return aSeq._retn(); +} + +//============================================================================= +/*! + * MakePipeTShapeTRFillet + * Create a T-shape object with specified caracteristics for the main and + * the incident pipes (radius, width, half-length). A fillet is created + * on the junction of the pipes. + * Center of the shape is (0,0,0). The main plane of the T-shape is XOY. + * \param theR1 Internal radius of main pipe + * \param theW1 Width of main pipe + * \param theL1 Half-length of main pipe + * \param theR2 Internal radius of incident pipe (R2 < R1) + * \param theW2 Width of incident pipe (R2+W2 < R1+W1) + * \param theL2 Half-length of incident pipe + * \param theRF Radius of curvature of fillet. + * \param theHexMesh Boolean indicating if shape is prepared for hex mesh + * \return List of GEOM_Objects, containing the created shape and propagation groups. + */ +//============================================================================= +GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeTRFillet + (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, + CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, + CORBA::Double theRL, CORBA::Double theWL, CORBA::Double theLtransL, CORBA::Double theLthinL, + CORBA::Double theRR, CORBA::Double theWR, CORBA::Double theLtransR, CORBA::Double theLthinR, + CORBA::Double theRI, CORBA::Double theWI, CORBA::Double theLtransI, CORBA::Double theLthinI, + CORBA::Double theRF, CORBA::Boolean theHexMesh) +{ + GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Create the TShape + Handle(TColStd_HSequenceOfTransient) aHSeq = + GetOperations()->MakePipeTShapeFillet(theR1, theW1, theL1, theR2, theW2, theL2, + theRL, theWL, theLtransL, theLthinL, + theRR, theWR, theLtransR, theLthinR, + theRI, theWI, theLtransI, theLthinI, + theRF, theHexMesh); + if (!GetOperations()->IsDone() || aHSeq.IsNull()) + return aSeq._retn(); + + Standard_Integer aLength = aHSeq->Length(); + aSeq->length(aLength); + for (Standard_Integer i = 1; i <= aLength; i++) + aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i))); + + return aSeq._retn(); +} + +//============================================================================= +/*! + * MakePipeTShapeTRFilletWithPosition + * Create a T-shape object with specified caracteristics for the main and + * the incident pipes (radius, width, half-length). A fillet is created + * on the junction of the pipes. + * The extremities of the main pipe are located on junctions points P1 and P2. + * The extremity of the incident pipe is located on junction point P3. + * \param theR1 Internal radius of main pipe + * \param theW1 Width of main pipe + * \param theL1 Half-length of main pipe + * \param theR2 Internal radius of incident pipe (R2 < R1) + * \param theW2 Width of incident pipe (R2+W2 < R1+W1) + * \param theL2 Half-length of incident pipe + * \param theRF Radius of curvature of fillet + * \param theHexMesh Boolean indicating if shape is prepared for hex mesh + * \param theP1 1st junction point of main pipe + * \param theP2 2nd junction point of main pipe + * \param theP3 Junction point of incident pipe + * \return List of GEOM_Objects, containing the created shape and propagation groups. + */ +//============================================================================= +GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeTRFilletWithPosition + (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, + CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, + CORBA::Double theRL, CORBA::Double theWL, CORBA::Double theLtransL, CORBA::Double theLthinL, + CORBA::Double theRR, CORBA::Double theWR, CORBA::Double theLtransR, CORBA::Double theLthinR, + CORBA::Double theRI, CORBA::Double theWI, CORBA::Double theLtransI, CORBA::Double theLthinI, + CORBA::Double theRF, CORBA::Boolean theHexMesh, + GEOM::GEOM_Object_ptr theP1, GEOM::GEOM_Object_ptr theP2, GEOM::GEOM_Object_ptr theP3) +{ + GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Get the reference vertices + Handle(GEOM_Object) aP1 = GetObjectImpl(theP1); + Handle(GEOM_Object) aP2 = GetObjectImpl(theP2); + Handle(GEOM_Object) aP3 = GetObjectImpl(theP3); + + //Create the TShape + Handle(TColStd_HSequenceOfTransient) aHSeq = + GetOperations()->MakePipeTShapeFilletWithPosition(theR1, theW1, theL1, theR2, theW2, theL2, + theRL, theWL, theLtransL, theLthinL, + theRR, theWR, theLtransR, theLthinR, + theRI, theWI, theLtransI, theLthinI, + theRF, theHexMesh, aP1, aP2, aP3); + if (!GetOperations()->IsDone() || aHSeq.IsNull()) + return aSeq._retn(); + + Standard_Integer aLength = aHSeq->Length(); + aSeq->length(aLength); + for (Standard_Integer i = 1; i <= aLength; i++) + aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i))); + + return aSeq._retn(); +} + +//============================================================================= +/*! + * This function allows to create a disk already divided into blocks. It can be + * use to create divided pipes for later meshing in hexaedra. + * \param theR Radius of the disk + * \param theRatio Relative size of the central square diagonal against the disk diameter + * \return New GEOM_Object, containing the created shape. + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IAdvancedOperations_i::MakeDividedDisk (CORBA::Double theR, + CORBA::Double theRatio, + CORBA::Short theOrientation, + GEOM::pattern thePattern) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Create the DividedDisk + Handle(GEOM_Object) anObject = GetOperations()->MakeDividedDisk(theR, theRatio, theOrientation, thePattern); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakeDividedDiskPntVecR + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IAdvancedOperations_i::MakeDividedDiskPntVecR (GEOM::GEOM_Object_ptr thePnt, + GEOM::GEOM_Object_ptr theVec, + CORBA::Double theR, + CORBA::Double theRatio, + GEOM::pattern thePattern) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Get the reference points + Handle(GEOM_Object) aPnt = GetObjectImpl(thePnt); + Handle(GEOM_Object) aVec = GetObjectImpl(theVec); + + if (aPnt.IsNull() || aVec.IsNull()) return aGEOMObject._retn(); + + // Make DividedDisk + Handle(GEOM_Object) anObject = + GetOperations()->MakeDividedDiskPntVecR(aPnt, aVec, theR, theRatio, thePattern); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * Builds a cylinder prepared for hexa meshes + * \param theR Radius of the cylinder + * \param theH Height of the cylinder + * \return New GEOM_Object, containing the created shape. + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IAdvancedOperations_i::MakeDividedCylinder (CORBA::Double theR, + CORBA::Double theH, + GEOM::pattern thePattern) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Create the DividedCylinder + Handle(GEOM_Object) anObject = GetOperations()->MakeDividedCylinder(theR, theH, thePattern); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * + * \param thelPoints list of points + * \return New GEOM_Object, containing the created shape. + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IAdvancedOperations_i::MakeSmoothingSurface (const GEOM::ListOfGO& thelPoints) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Get the reference point + int ind = 0; + int aLen = thelPoints.length(); + std::list aPoints; + for (; ind < aLen; ind++) { + Handle(GEOM_Object) aPnt = GetObjectImpl(thelPoints[ind]); + if (aPnt.IsNull()) return aGEOMObject._retn(); + aPoints.push_back(aPnt); + } + //Create the SmoothingSurface + Handle(GEOM_Object) anObject = GetOperations()->MakeSmoothingSurface(aPoints); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +/*@@ insert new functions before this line @@ do not remove this line @@*/ diff --git a/src/AdvancedEngine/GEOM_IAdvancedOperations_i.hh b/src/AdvancedEngine/GEOM_IAdvancedOperations_i.hh new file mode 100644 index 000000000..151049e8c --- /dev/null +++ b/src/AdvancedEngine/GEOM_IAdvancedOperations_i.hh @@ -0,0 +1,136 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// File : GEOM_IAdvancedOperations.hh +// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) + +#ifndef _GEOM_IAdvancedOperations_i_HeaderFile +#define _GEOM_IAdvancedOperations_i_HeaderFile + +#include "GEOMImpl_Gen.hxx" + +#include + +#include CORBA_SERVER_HEADER(GEOM_Gen) +#include "GEOM_IOperations_i.hh" +#include "GEOM_Object_i.hh" + +#include "GEOMImpl_IAdvancedOperations.hxx" + +class GEOM_I_EXPORT GEOM_IAdvancedOperations_i : + public virtual POA_GEOM::GEOM_IAdvancedOperations, + public virtual GEOM_IOperations_i +{ + public: + GEOM_IAdvancedOperations_i (PortableServer::POA_ptr thePOA, GEOM::GEOM_Gen_ptr theEngine, + ::GEOMImpl_IAdvancedOperations* theImpl); + ~GEOM_IAdvancedOperations_i(); + + // PipeTShape without thickness reduction + GEOM::ListOfGO* MakePipeTShape (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, + CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, + CORBA::Boolean theHexMesh); + GEOM::ListOfGO* MakePipeTShapeWithPosition (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, + CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, + CORBA::Boolean theHexMesh, + GEOM::GEOM_Object_ptr theP1, GEOM::GEOM_Object_ptr theP2, GEOM::GEOM_Object_ptr theP3); + GEOM::ListOfGO* MakePipeTShapeChamfer (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, + CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, + CORBA::Double theH, CORBA::Double theW, CORBA::Boolean theHexMesh); + GEOM::ListOfGO* MakePipeTShapeChamferWithPosition (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, + CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, + CORBA::Double theH, CORBA::Double theW, CORBA::Boolean theHexMesh, + GEOM::GEOM_Object_ptr theP1, GEOM::GEOM_Object_ptr theP2, GEOM::GEOM_Object_ptr theP3); + GEOM::ListOfGO* MakePipeTShapeFillet (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, + CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, + CORBA::Double theRF, CORBA::Boolean theHexMesh); + GEOM::ListOfGO* MakePipeTShapeFilletWithPosition (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, + CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, + CORBA::Double theRF, CORBA::Boolean theHexMesh, + GEOM::GEOM_Object_ptr theP1, GEOM::GEOM_Object_ptr theP2, GEOM::GEOM_Object_ptr theP3); + + // PipeTShape with thickness reduction + GEOM::ListOfGO* MakePipeTShapeTR + (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, + CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, + CORBA::Double theRL, CORBA::Double theWL, CORBA::Double theLtransL, CORBA::Double theLthinL, + CORBA::Double theRR, CORBA::Double theWR, CORBA::Double theLtransR, CORBA::Double theLthinR, + CORBA::Double theRI, CORBA::Double theWI, CORBA::Double theLtransI, CORBA::Double theLthinI, + CORBA::Boolean theHexMesh); + GEOM::ListOfGO* MakePipeTShapeTRWithPosition + (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, + CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, + CORBA::Double theRL, CORBA::Double theWL, CORBA::Double theLtransL, CORBA::Double theLthinL, + CORBA::Double theRR, CORBA::Double theWR, CORBA::Double theLtransR, CORBA::Double theLthinR, + CORBA::Double theRI, CORBA::Double theWI, CORBA::Double theLtransI, CORBA::Double theLthinI, + CORBA::Boolean theHexMesh, + GEOM::GEOM_Object_ptr theP1, GEOM::GEOM_Object_ptr theP2, GEOM::GEOM_Object_ptr theP3); + GEOM::ListOfGO* MakePipeTShapeTRChamfer + (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, + CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, + CORBA::Double theRL, CORBA::Double theWL, CORBA::Double theLtransL, CORBA::Double theLthinL, + CORBA::Double theRR, CORBA::Double theWR, CORBA::Double theLtransR, CORBA::Double theLthinR, + CORBA::Double theRI, CORBA::Double theWI, CORBA::Double theLtransI, CORBA::Double theLthinI, + CORBA::Double theH, CORBA::Double theW, CORBA::Boolean theHexMesh); + GEOM::ListOfGO* MakePipeTShapeTRChamferWithPosition + (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, + CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, + CORBA::Double theRL, CORBA::Double theWL, CORBA::Double theLtransL, CORBA::Double theLthinL, + CORBA::Double theRR, CORBA::Double theWR, CORBA::Double theLtransR, CORBA::Double theLthinR, + CORBA::Double theRI, CORBA::Double theWI, CORBA::Double theLtransI, CORBA::Double theLthinI, + CORBA::Double theH, CORBA::Double theW, CORBA::Boolean theHexMesh, + GEOM::GEOM_Object_ptr theP1, GEOM::GEOM_Object_ptr theP2, GEOM::GEOM_Object_ptr theP3); + GEOM::ListOfGO* MakePipeTShapeTRFillet + (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, + CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, + CORBA::Double theRL, CORBA::Double theWL, CORBA::Double theLtransL, CORBA::Double theLthinL, + CORBA::Double theRR, CORBA::Double theWR, CORBA::Double theLtransR, CORBA::Double theLthinR, + CORBA::Double theRI, CORBA::Double theWI, CORBA::Double theLtransI, CORBA::Double theLthinI, + CORBA::Double theRF, CORBA::Boolean theHexMesh); + GEOM::ListOfGO* MakePipeTShapeTRFilletWithPosition + (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, + CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, + CORBA::Double theRL, CORBA::Double theWL, CORBA::Double theLtransL, CORBA::Double theLthinL, + CORBA::Double theRR, CORBA::Double theWR, CORBA::Double theLtransR, CORBA::Double theLthinR, + CORBA::Double theRI, CORBA::Double theWI, CORBA::Double theLtransI, CORBA::Double theLthinI, + CORBA::Double theRF, CORBA::Boolean theHexMesh, + GEOM::GEOM_Object_ptr theP1, GEOM::GEOM_Object_ptr theP2, GEOM::GEOM_Object_ptr theP3); + + GEOM::GEOM_Object_ptr MakeDividedDisk (CORBA::Double theR, + CORBA::Double theRatio, + CORBA::Short theOrientation, + GEOM::pattern thePattern); + + GEOM::GEOM_Object_ptr MakeDividedDiskPntVecR (GEOM::GEOM_Object_ptr theCenter, + GEOM::GEOM_Object_ptr theVector, + CORBA::Double theR, + CORBA::Double theRatio, + GEOM::pattern thePattern); + + GEOM::GEOM_Object_ptr MakeDividedCylinder (CORBA::Double theR, + CORBA::Double theH, + GEOM::pattern thePattern); + GEOM::GEOM_Object_ptr MakeSmoothingSurface (const GEOM::ListOfGO& thelPoints); + /*@@ insert new functions before this line @@ do not remove this line @@*/ + + ::GEOMImpl_IAdvancedOperations* GetOperations() + { return (::GEOMImpl_IAdvancedOperations*)GetImpl(); } +}; + +#endif diff --git a/src/AdvancedEngine/Makefile.am b/src/AdvancedEngine/Makefile.am new file mode 100644 index 000000000..a8af35ffc --- /dev/null +++ b/src/AdvancedEngine/Makefile.am @@ -0,0 +1,83 @@ +# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com + +include $(top_srcdir)/adm_local/unix/make_common_starter.am + +# Libraries targets +lib_LTLIBRARIES = libAdvancedEngine.la + +# header files +salomeinclude_HEADERS = \ + AdvancedEngine_Types.hxx \ + AdvancedEngine_OperationsCreator.hh \ + GEOM_AdvancedEngine.hxx \ + GEOMImpl_IAdvancedOperations.hxx \ + GEOM_IAdvancedOperations_i.hh + +ADVANCED_INCLUDES = +ADVANCED_INCLUDES += GEOMImpl_IPipeTShape.hxx GEOMImpl_PipeTShapeDriver.hxx +ADVANCED_INCLUDES += GEOMImpl_IDividedDisk.hxx GEOMImpl_DividedDiskDriver.hxx +##ADVANCED_INCLUDES += GEOMImpl_IDividedCylinder.hxx GEOMImpl_DividedCylinderDriver.hxx +ADVANCED_INCLUDES += GEOMImpl_ISmoothingSurface.hxx GEOMImpl_SmoothingSurfaceDriver.hxx +##@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@## + +salomeinclude_HEADERS += $(ADVANCED_INCLUDES) + +dist_libAdvancedEngine_la_SOURCES = \ + AdvancedEngine.cxx \ + AdvancedEngine_OperationsCreator.cc \ + GEOMImpl_IAdvancedOperations.cxx \ + GEOM_IAdvancedOperations_i.cc + +ADVANCED_SOURCES = +ADVANCED_SOURCES += GEOMImpl_PipeTShapeDriver.cxx +ADVANCED_SOURCES += GEOMImpl_DividedDiskDriver.cxx +##ADVANCED_SOURCES += GEOMImpl_DividedCylinderDriver.cxx +ADVANCED_SOURCES += GEOMImpl_SmoothingSurfaceDriver.cxx +##@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@## + +dist_libAdvancedEngine_la_SOURCES += $(ADVANCED_SOURCES) + +# additional information to compile and link file + +libAdvancedEngine_la_CPPFLAGS = \ + $(CORBA_CXXFLAGS) \ + $(CORBA_INCLUDES) \ + $(CAS_CPPFLAGS) \ + $(BOOST_CPPFLAGS) \ + $(KERNEL_CXXFLAGS) \ + -I$(srcdir)/../GEOMUtils \ + -I$(srcdir)/../NMTDS \ + -I$(srcdir)/../NMTTools \ + -I$(srcdir)/../GEOMAlgo \ + -I$(srcdir)/../GEOM \ + -I$(srcdir)/../GEOMImpl \ + -I$(srcdir)/../GEOM_I \ + -I$(top_builddir)/idl \ + -I$(top_builddir) + +libAdvancedEngine_la_LDFLAGS = \ + ../../idl/libSalomeIDLGEOM.la \ + ../GEOMUtils/libGEOMUtils.la \ + ../GEOMAlgo/libGEOMAlgo.la \ + ../GEOM/libGEOMbasic.la \ + ../GEOMImpl/libGEOMimpl.la \ + ../GEOM_I/libGEOMEngine.la \ + $(KERNEL_LDFLAGS) -lOpUtil -lSalomeNS -lSalomeContainer -lSalomeGenericObj -lTOOLSDS \ + $(CAS_DATAEXCHANGE) \ + $(CAS_LDPATH) -lTKFillet -lTKOffset diff --git a/src/AdvancedGUI/AdvancedGUI.cxx b/src/AdvancedGUI/AdvancedGUI.cxx index 818f4c276..12aec5c8f 100644 --- a/src/AdvancedGUI/AdvancedGUI.cxx +++ b/src/AdvancedGUI/AdvancedGUI.cxx @@ -23,7 +23,7 @@ #include "AdvancedGUI.h" #include "GeometryGUI.h" -#include "GeometryGUI_Operations.h" +//#include "GeometryGUI_Operations.h" #include #include @@ -36,11 +36,13 @@ #include +#include + //======================================================================= // function : AdvancedGUI() // purpose : Constructor //======================================================================= -AdvancedGUI::AdvancedGUI( GeometryGUI* parent ) : GEOMGUI( parent ) +AdvancedGUI::AdvancedGUI( GeometryGUI* parent ) : GEOMPluginGUI( parent ) { } @@ -57,6 +59,28 @@ AdvancedGUI::~AdvancedGUI() // purpose : //======================================================================= bool AdvancedGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent ) +{ + switch ( theCommandID ) { + case 1: + return OnGUIEvent("TShape_Basic", parent); + case 2: + return OnGUIEvent("DividedDisk", parent); + case 3: + return OnGUIEvent("DividedCylinder", parent); + case 4: + return OnGUIEvent("SmoothingSurface", parent); + //@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@// + default: + return OnGUIEvent("", parent); + } + return false; +} + +//======================================================================= +// function : OnGUIEvent() +// purpose : +//======================================================================= +bool AdvancedGUI::OnGUIEvent( const QString& theCommandID, SUIT_Desktop* parent ) { SalomeApp_Application* app = getGeometryGUI()->getApp(); if ( !app ) return false; @@ -65,26 +89,24 @@ bool AdvancedGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent ) QDialog* aDlg = NULL; - switch ( theCommandID ) { - case GEOMOp::OpPipeTShape: + if (theCommandID == "TShape_Basic") { aDlg = new AdvancedGUI_PipeTShapeDlg( getGeometryGUI(), parent ); - break; -// case GEOMOp::OpPipeTShapeGroups: -// aDlg = new AdvancedGUI_PipeTShapeGroupsDlg( getGeometryGUI(), parent ); -// break; - case GEOMOp::OpDividedDisk: + } + //else if (theCommandID == "TShape_Groups") { + // aDlg = new AdvancedGUI_PipeTShapeGroupsDlg( getGeometryGUI(), parent ); + //} + else if (theCommandID == "DividedDisk") { aDlg = new AdvancedGUI_DividedDiskDlg( getGeometryGUI(), parent ); - break; - case GEOMOp::OpDividedCylinder: + } + else if (theCommandID == "DividedCylinder") { aDlg = new AdvancedGUI_DividedCylinderDlg( getGeometryGUI(), parent ); - break; - case GEOMOp::OpSmoothingSurface: + } + else if (theCommandID == "SmoothingSurface") { aDlg = new AdvancedGUI_SmoothingSurfaceDlg( getGeometryGUI(), parent ); - break; + } //@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@// - default: + else { app->putInfo( tr( "GEOM_PRP_COMMAND" ).arg( theCommandID ) ); - break; } if ( aDlg != NULL ) @@ -101,7 +123,7 @@ extern "C" #ifdef WIN32 __declspec( dllexport ) #endif - GEOMGUI* GetLibGUI( GeometryGUI* parent ) + GEOMPluginGUI* GetLibGUI( GeometryGUI* parent ) { return new AdvancedGUI( parent ); } diff --git a/src/AdvancedGUI/AdvancedGUI.h b/src/AdvancedGUI/AdvancedGUI.h index 2ee00afc9..7d746c5d5 100644 --- a/src/AdvancedGUI/AdvancedGUI.h +++ b/src/AdvancedGUI/AdvancedGUI.h @@ -23,19 +23,20 @@ #ifndef ADVANCEDGUI_H #define ADVANCEDGUI_H -#include "GEOMGUI.h" +#include "GEOMPluginGUI.h" //================================================================================= // class : AdvancedGUI // purpose : //================================================================================= -class AdvancedGUI : public GEOMGUI +class AdvancedGUI : public GEOMPluginGUI { public: AdvancedGUI( GeometryGUI* ); ~AdvancedGUI(); bool OnGUIEvent( int, SUIT_Desktop* ); + bool OnGUIEvent( const QString&, SUIT_Desktop* ); }; #endif // ADVANCEDGUI_H diff --git a/src/AdvancedGUI/AdvancedGUI_DividedCylinderDlg.cxx b/src/AdvancedGUI/AdvancedGUI_DividedCylinderDlg.cxx index e87bf882a..77eb987a4 100644 --- a/src/AdvancedGUI/AdvancedGUI_DividedCylinderDlg.cxx +++ b/src/AdvancedGUI/AdvancedGUI_DividedCylinderDlg.cxx @@ -217,7 +217,8 @@ void AdvancedGUI_DividedCylinderDlg::ValueChangedInSpinBox() //================================================================================= GEOM::GEOM_IOperations_ptr AdvancedGUI_DividedCylinderDlg::createOperation() { - return getGeomEngine()->GetIAdvancedOperations(getStudyId()); + //return getGeomEngine()->GetIAdvancedOperations(getStudyId()); + return getGeomEngine()->GetPluginOperations(getStudyId(), "AdvancedEngine"); } //================================================================================= diff --git a/src/AdvancedGUI/AdvancedGUI_DividedDiskDlg.cxx b/src/AdvancedGUI/AdvancedGUI_DividedDiskDlg.cxx index ecf1f1325..76e1a68f0 100644 --- a/src/AdvancedGUI/AdvancedGUI_DividedDiskDlg.cxx +++ b/src/AdvancedGUI/AdvancedGUI_DividedDiskDlg.cxx @@ -392,7 +392,8 @@ void AdvancedGUI_DividedDiskDlg::ValueChangedInSpinBox() //================================================================================= GEOM::GEOM_IOperations_ptr AdvancedGUI_DividedDiskDlg::createOperation() { - return getGeomEngine()->GetIAdvancedOperations(getStudyId()); + //return getGeomEngine()->GetIAdvancedOperations(getStudyId()); + return getGeomEngine()->GetPluginOperations(getStudyId(), "AdvancedEngine"); } //================================================================================= diff --git a/src/AdvancedGUI/AdvancedGUI_PipeTShapeDlg.cxx b/src/AdvancedGUI/AdvancedGUI_PipeTShapeDlg.cxx index 748004596..4e686ea82 100644 --- a/src/AdvancedGUI/AdvancedGUI_PipeTShapeDlg.cxx +++ b/src/AdvancedGUI/AdvancedGUI_PipeTShapeDlg.cxx @@ -844,7 +844,8 @@ void AdvancedGUI_PipeTShapeDlg::DisplayPreview (const bool activate, const bool //================================================================================= GEOM::GEOM_IOperations_ptr AdvancedGUI_PipeTShapeDlg::createOperation() { - return getGeomEngine()->GetIAdvancedOperations(getStudyId()); + //return getGeomEngine()->GetIAdvancedOperations(getStudyId()); + return getGeomEngine()->GetPluginOperations(getStudyId(), "AdvancedEngine"); } //================================================================================= diff --git a/src/AdvancedGUI/AdvancedGUI_SmoothingSurfaceDlg.cxx b/src/AdvancedGUI/AdvancedGUI_SmoothingSurfaceDlg.cxx index 2f8a5febd..9a1d4107b 100644 --- a/src/AdvancedGUI/AdvancedGUI_SmoothingSurfaceDlg.cxx +++ b/src/AdvancedGUI/AdvancedGUI_SmoothingSurfaceDlg.cxx @@ -158,7 +158,8 @@ void AdvancedGUI_SmoothingSurfaceDlg::enterEvent (QEvent*) //================================================================================= GEOM::GEOM_IOperations_ptr AdvancedGUI_SmoothingSurfaceDlg::createOperation() { - return getGeomEngine()->GetIAdvancedOperations(getStudyId()); + //return getGeomEngine()->GetIAdvancedOperations(getStudyId()); + return getGeomEngine()->GetPluginOperations(getStudyId(), "AdvancedEngine"); } //================================================================================= diff --git a/src/AdvancedGUI/AdvancedGUI_images.ts b/src/AdvancedGUI/AdvancedGUI_images.ts new file mode 100644 index 000000000..3dd602c67 --- /dev/null +++ b/src/AdvancedGUI/AdvancedGUI_images.ts @@ -0,0 +1,177 @@ + + + + + @default + + ICON_OBJBROWSER_ADVANCED_201 + tree_pipetshape.png + + + ICON_OBJBROWSER_ADVANCED_202 + divided_disk.png + + + ICON_OBJBROWSER_ADVANCED_203 + dividedcylinder.png + + + ICON_OBJBROWSER_ADVANCED_204 + tree_smoothingsurface.png + + + + ICON_DLG_PIPETSHAPE + pipetshape.png + + + ICO_PIPETSHAPE + pipetshape.png + + + ICO_PIPETSHAPE_IMPORT + pipetshape_import_icon.png + + + DLG_PIPETSHAPE + dlg_pipetshape.png + + + IMG_PIPETSHAPE_SECT + pipetshape_section.png + + + DLG_PIPETSHAPE_L1 + dlg_pipetshapel1.png + + + DLG_PIPETSHAPE_R1 + dlg_pipetshaper1.png + + + DLG_PIPETSHAPE_W1 + dlg_pipetshapew1.png + + + DLG_PIPETSHAPE_L2 + dlg_pipetshapel2.png + + + DLG_PIPETSHAPE_R2 + dlg_pipetshaper2.png + + + DLG_PIPETSHAPE_W2 + dlg_pipetshapew2.png + + + + DLG_PIPETSHAPE_FILLET + dlg_pipetshapefillet.png + + + DLG_PIPETSHAPE_FILLET_L1 + dlg_pipetshapefilletl1.png + + + DLG_PIPETSHAPE_FILLET_R1 + dlg_pipetshapefilletr1.png + + + DLG_PIPETSHAPE_FILLET_W1 + dlg_pipetshapefilletw1.png + + + DLG_PIPETSHAPE_FILLET_L2 + dlg_pipetshapefilletl2.png + + + DLG_PIPETSHAPE_FILLET_R2 + dlg_pipetshapefilletr2.png + + + DLG_PIPETSHAPE_FILLET_W2 + dlg_pipetshapefilletw2.png + + + DLG_PIPETSHAPE_FILLET_RF + dlg_pipetshapefilletrf.png + + + + DLG_PIPETSHAPE_CHAMFER + dlg_pipetshapechamfer.png + + + DLG_PIPETSHAPE_CHAMFER_L1 + dlg_pipetshapechamferl1.png + + + DLG_PIPETSHAPE_CHAMFER_R1 + dlg_pipetshapechamferr1.png + + + DLG_PIPETSHAPE_CHAMFER_W1 + dlg_pipetshapechamferw1.png + + + DLG_PIPETSHAPE_CHAMFER_L2 + dlg_pipetshapechamferl2.png + + + DLG_PIPETSHAPE_CHAMFER_R2 + dlg_pipetshapechamferr2.png + + + DLG_PIPETSHAPE_CHAMFER_W2 + dlg_pipetshapechamferw2.png + + + DLG_PIPETSHAPE_CHAMFER_H + dlg_pipetshapechamferh.png + + + DLG_PIPETSHAPE_CHAMFER_W + dlg_pipetshapechamferw.png + + + + + + ICON_DLG_DIVIDEDDISK_R_RATIO + divided_disk.png + + + ICO_DIVIDEDDISK + divided_disk.png + + + + ICON_DLG_DIVIDEDCYLINDER_R_H + dividedcylinder_r_h.png + + + ICO_DIVIDEDCYLINDER + dividedcylinder.png + + + + ICON_DLG_SMOOTHINGSURFACE_LPOINTS + smoothingsurface_lpoints.png + + + ICO_SMOOTHINGSURFACE + smoothingsurface.png + + + + diff --git a/src/AdvancedGUI/AdvancedGUI_msg_en.ts b/src/AdvancedGUI/AdvancedGUI_msg_en.ts new file mode 100644 index 000000000..e7524147c --- /dev/null +++ b/src/AdvancedGUI/AdvancedGUI_msg_en.ts @@ -0,0 +1,273 @@ + + + + + @default + + GEOM_ADVANCED + Advanced shape: type %1 + + + GEOM_ADVANCED_201 + Pipe TShape + + + GEOM_ADVANCED_202 + Divided Disk + + + GEOM_ADVANCED_203 + Divided Cylinder + + + GEOM_DIVIDEDDISK + Divided Disk + + + GEOM_DIVIDEDDISK_TITLE + Divided Disk construction + + + GEOM_DIVIDEDCYLINDER + Divided Cylinder + + + GEOM_DIVIDEDCYLINDER_TITLE + Divided Cylinder construction + + + MEN_DIVIDEDCYLINDER + Divided Cylinder + + + TOP_DIVIDEDCYLINDER + Divided Cylinder + + + STB_DIVIDEDCYLINDER + Divided Cylinder + + + MEN_DIVIDEDDISK + Divided Disk + + + TOP_DIVIDEDDISK + Divided Disk + + + STB_DIVIDEDDISK + Divided Disk + + + TOP_PIPETSHAPE + Create Pipe TShape + + + MEN_PIPETSHAPE + Pipe TShape + + + STB_PIPETSHAPE + Create new Pipe TShape object + + + TOP_SMOOTHINGSURFACE + Smoothing Surface + + + MEN_SMOOTHINGSURFACE + Smoothing Surface + + + STB_SMOOTHINGSURFACE + Smoothing Surface + + + HALF_LENGTH_MAIN_PIPE + Main pipe half length + + + HALF_LENGTH_INCIDENT_PIPE + Incident pipe half length + + + CIRCULAR_QUARTER_PIPE + Circular quarter of pipe + + + THICKNESS + Thickness + + + FLANGE + Flange + + + CHAMFER_OR_FILLET + Chamfer or fillet + + + CHAMFER + Chamfer + + + FILLET + Fillet + + + JUNCTION_FACE_1 + Junction 1 + + + JUNCTION_FACE_2 + Junction 2 + + + JUNCTION_FACE_3 + Junction 3 + + + INTERNAL_FACES + Internal faces + + + + AdvancedGUI_PipeTShapeDlg + + GEOM_PIPE_TSHAPE_TITLE + Pipe TShape Construction + + + GEOM_PIPE_TSHAPE + PipeTShape + + + GEOM_PIPE_TSHAPE_MPIPE + Main pipe + + + GEOM_PIPE_TSHAPE_R + Radius + + + GEOM_PIPE_TSHAPE_W + Width + + + GEOM_PIPE_TSHAPE_L + Half-length + + + GEOM_PIPE_TSHAPE_IPIPE + Incident pipe + + + GEOM_PIPE_TSHAPE_CHAMFER + Chamfer + + + GEOM_PIPE_TSHAPE_CHAMFER_H + Height + + + GEOM_PIPE_TSHAPE_CHAMFER_W + Width + + + GEOM_PIPE_TSHAPE_FILLET + Fillet + + + GEOM_PIPE_TSHAPE_HEX + Prepare for hex mesh + + + GEOM_PIPE_TSHAPE_POSITION + Set position + + + GEOM_PIPE_TSHAPE_POSITION_P1 + Junction P1 + + + GEOM_PIPE_TSHAPE_POSITION_P2 + Junction P2 + + + GEOM_PIPE_TSHAPE_POSITION_P3 + Junction P3 + + + GEOM_PIPE_TSHAPE_POSITION_LBL_L1 + New L1 + + + GEOM_PIPE_TSHAPE_POSITION_LBL_L2 + New L2 + + + GEOM_PIPE_TSHAPE_LEFT_TR + Left thickness reduction + + + GEOM_PIPE_TSHAPE_RIGHT_TR + Right thickness reduction + + + GEOM_PIPE_TSHAPE_INCI_TR + Incident pipe thickness reduction + + + GEOM_PIPE_TSHAPE_TR_R + Radius (r%1) + + + GEOM_PIPE_TSHAPE_TR_W + Width (w%1) + + + GEOM_PIPE_TSHAPE_TR_L_TRANS + Transition length (ltrans%1) + + + GEOM_PIPE_TSHAPE_TR_L_THIN + Thin part length (lthin%1) + + + GEOM_PIPETSHAPE_GROUPMAIN + Main parameters + + + GEOM_PIPETSHAPE_GROUPREDUCT + Thickness reduction + + + GEOM_PIPETSHAPE_GROUPPOS + Position + + + + AdvancedGUI_SmoothingSurfaceDlg + + GEOM_SMOOTHINGSURFACE_TITLE + Smoothing surface Construction + + + GEOM_SMOOTHINGSURFACE + Smoothing surface + + + GEOM_SMOOTHINGSURFACE_RESULT + Result name + + + GEOM_SMOOTHINGSURFACE_ARG + Nodes + + + GEOM_SMOOTHINGSURFACE_ARG_POINTS + Points + + + diff --git a/src/AdvancedGUI/AdvancedGUI_msg_fr.ts b/src/AdvancedGUI/AdvancedGUI_msg_fr.ts new file mode 100644 index 000000000..69c38cbc9 --- /dev/null +++ b/src/AdvancedGUI/AdvancedGUI_msg_fr.ts @@ -0,0 +1,273 @@ + + + + + @default + + GEOM_ADVANCED + Objet géométrique avancé : type %1 + + + GEOM_ADVANCED_201 + Tuyau en T + + + GEOM_ADVANCED_202 + Disque prédécoupé + + + GEOM_ADVANCED_203 + Cylindre prédécoupé + + + GEOM_DIVIDEDDISK + Disque prédécoupé + + + GEOM_DIVIDEDDISK_TITLE + Construction d'un disque prédécoupé + + + GEOM_DIVIDEDCYLINDER + Cylinder prédécoupé + + + GEOM_DIVIDEDCYLINDER_TITLE + Construction d'un cylindre prédécoupé + + + MEN_DIVIDEDCYLINDER + Cylinder prédécoupé + + + TOP_DIVIDEDCYLINDER + Cylinder prédécoupé + + + STB_DIVIDEDCYLINDER + Cylinder prédécoupé + + + MEN_DIVIDEDDISK + Disque prédécoupé + + + TOP_DIVIDEDDISK + Disque prédécoupé + + + STB_DIVIDEDDISK + Disque prédécoupé + + + TOP_PIPETSHAPE + Créer un tuyau en T + + + MEN_PIPETSHAPE + Tuyau en T + + + STB_PIPETSHAPE + Créer un tuyau en T + + + TOP_SMOOTHINGSURFACE + Smoothing Surface + + + MEN_SMOOTHINGSURFACE + Smoothing Surface + + + STB_SMOOTHINGSURFACE + Smoothing Surface + + + HALF_LENGTH_MAIN_PIPE + Demi-longueur du tuyau principal + + + HALF_LENGTH_INCIDENT_PIPE + Demi-longueur du tuyau incident + + + CIRCULAR_QUARTER_PIPE + Un quart circulaire du tuyau + + + THICKNESS + Epaisseur + + + FLANGE + Collerette + + + CHAMFER_OR_FILLET + Chanfrein ou congé + + + CHAMFER + Chanfrein + + + FILLET + Congé + + + JUNCTION_FACE_1 + Jonction 1 + + + JUNCTION_FACE_2 + Jonction 2 + + + JUNCTION_FACE_3 + Jonction 3 + + + INTERNAL_FACES + Internal faces + + + + AdvancedGUI_PipeTShapeDlg + + GEOM_PIPE_TSHAPE_TITLE + Construction d'un tuyau en T + + + GEOM_PIPE_TSHAPE + Tuyau en T + + + GEOM_PIPE_TSHAPE_MPIPE + Tuyau principal + + + GEOM_PIPE_TSHAPE_R + Rayon + + + GEOM_PIPE_TSHAPE_W + Largeur + + + GEOM_PIPE_TSHAPE_L + Demi-longueur + + + GEOM_PIPE_TSHAPE_IPIPE + Tuyau incident + + + GEOM_PIPE_TSHAPE_CHAMFER + Chanfrein + + + GEOM_PIPE_TSHAPE_CHAMFER_H + Hauteur + + + GEOM_PIPE_TSHAPE_CHAMFER_W + Largeur + + + GEOM_PIPE_TSHAPE_FILLET + Congé + + + GEOM_PIPE_TSHAPE_HEX + Préparer pour un maillage hexaédrique + + + GEOM_PIPE_TSHAPE_POSITION + Définir la position + + + GEOM_PIPE_TSHAPE_POSITION_P1 + Jonction P1 + + + GEOM_PIPE_TSHAPE_POSITION_P2 + Jonction P2 + + + GEOM_PIPE_TSHAPE_POSITION_P3 + Jonction P3 + + + GEOM_PIPE_TSHAPE_POSITION_LBL_L1 + Nouvelle L1 + + + GEOM_PIPE_TSHAPE_POSITION_LBL_L2 + Nouvelle L2 + + + GEOM_PIPE_TSHAPE_LEFT_TR + Réduction d'épaisseur à gauche + + + GEOM_PIPE_TSHAPE_RIGHT_TR + Réduction d'épaisseur à droite + + + GEOM_PIPE_TSHAPE_INCI_TR + Réduction d'épaisseur du tuyau incident + + + GEOM_PIPE_TSHAPE_TR_R + Rayon (r%1) + + + GEOM_PIPE_TSHAPE_TR_W + Epaisseur (w%1) + + + GEOM_PIPE_TSHAPE_TR_L_TRANS + Longueur de transition (ltrans%1) + + + GEOM_PIPE_TSHAPE_TR_L_THIN + Longueur de la partie étroite (lthin%1) + + + GEOM_PIPETSHAPE_GROUPMAIN + Paramètres principaux + + + GEOM_PIPETSHAPE_GROUPREDUCT + Réduction d'épaisseur + + + GEOM_PIPETSHAPE_GROUPPOS + Position + + + + AdvancedGUI_SmoothingSurfaceDlg + + GEOM_SMOOTHINGSURFACE_TITLE + Constructions de surface lisse + + + GEOM_SMOOTHINGSURFACE + Surface lissee + + + GEOM_SMOOTHINGSURFACE_RESULT + Nom du résultat + + + GEOM_SMOOTHINGSURFACE_ARG + Noeuds + + + GEOM_SMOOTHINGSURFACE_ARG_POINTS + Points + + + diff --git a/src/AdvancedGUI/AdvancedGUI_msg_ja.ts b/src/AdvancedGUI/AdvancedGUI_msg_ja.ts new file mode 100644 index 000000000..186e19fb7 --- /dev/null +++ b/src/AdvancedGUI/AdvancedGUI_msg_ja.ts @@ -0,0 +1,233 @@ + + + + + @default + + GEOM_ADVANCED + 形状を高度な:%1 入力 + + + GEOM_ADVANCED_201 + TShape をパイプします。 + + + GEOM_ADVANCED_202 + 分割ディスク + + + GEOM_ADVANCED_203 + 分割シリンダー + + + GEOM_DIVIDEDDISK + 分割ディスク + + + GEOM_DIVIDEDDISK_TITLE + 分割ディスク建設 + + + GEOM_DIVIDEDCYLINDER + 分割シリンダー + + + GEOM_DIVIDEDCYLINDER_TITLE + 分割構造 + + + MEN_DIVIDEDCYLINDER + 分割シリンダー + + + TOP_DIVIDEDCYLINDER + 分割シリンダー + + + STB_DIVIDEDCYLINDER + 分割シリンダー + + + MEN_DIVIDEDDISK + 分割ディスク + + + TOP_DIVIDEDDISK + 分割ディスク + + + STB_DIVIDEDDISK + 分割ディスク + + + TOP_PIPETSHAPE + TShape パイプを作成します。 + + + MEN_PIPETSHAPE + TShape をパイプします。 + + + STB_PIPETSHAPE + 新しいパイプ TShape オブジェクトを作成します。 + + + TOP_SMOOTHINGSURFACE + Smoothing Surface + + + MEN_SMOOTHINGSURFACE + Smoothing Surface + + + STB_SMOOTHINGSURFACE + Smoothing Surface + + + HALF_LENGTH_MAIN_PIPE + 主配管の長さの半分 + + + HALF_LENGTH_INCIDENT_PIPE + インシデント管長さの半分 + + + CIRCULAR_QUARTER_PIPE + 円形の四半期パイプの + + + THICKNESS + 厚 + + + FLANGE + フランジ + + + CHAMFER_OR_FILLET + 面取りまたはフィレット + + + CHAMFER + 面取り + + + FILLET + フィレット + + + JUNCTION_FACE_1 + ジャンクション 1 + + + JUNCTION_FACE_2 + ジャンクション 2 + + + JUNCTION_FACE_3 + ジャンクション 3 + + + INTERNAL_FACES + Internal faces + + + + AdvancedGUI_PipeTShapeDlg + + GEOM_PIPE_TSHAPE_TITLE + パイプ TShape 建設 + + + GEOM_PIPE_TSHAPE + PipeTShape + + + GEOM_PIPE_TSHAPE_MPIPE + 主配管 + + + GEOM_PIPE_TSHAPE_R + 半径 + + + GEOM_PIPE_TSHAPE_W + 幅 + + + GEOM_PIPE_TSHAPE_L + ハーフレングス + + + GEOM_PIPE_TSHAPE_IPIPE + インシデント管 + + + GEOM_PIPE_TSHAPE_CHAMFER + 面取り + + + GEOM_PIPE_TSHAPE_CHAMFER_H + 高さ + + + GEOM_PIPE_TSHAPE_CHAMFER_W + 幅 + + + GEOM_PIPE_TSHAPE_FILLET + フィレット + + + GEOM_PIPE_TSHAPE_HEX + 16 進数のメッシュのための準備します。 + + + GEOM_PIPE_TSHAPE_POSITION + 位置の設定 + + + GEOM_PIPE_TSHAPE_POSITION_P1 + ジャンクション P1 + + + GEOM_PIPE_TSHAPE_POSITION_P2 + ジャンクション P2 + + + GEOM_PIPE_TSHAPE_POSITION_P3 + ジャンクション P3 + + + GEOM_PIPE_TSHAPE_POSITION_LBL_L1 + 新しい L1 + + + GEOM_PIPE_TSHAPE_POSITION_LBL_L2 + 新しい L2 + + + + AdvancedGUI_SmoothingSurfaceDlg + + GEOM_SMOOTHINGSURFACE_TITLE + Smoothing surface Construction + + + GEOM_SMOOTHINGSURFACE + Smoothing surface + + + GEOM_SMOOTHINGSURFACE_RESULT + Result name + + + GEOM_SMOOTHINGSURFACE_ARG + Nodes + + + GEOM_SMOOTHINGSURFACE_ARG_POINTS + Points + + + diff --git a/src/AdvancedGUI/Makefile.am b/src/AdvancedGUI/Makefile.am index ae8aca2ea..436727e37 100644 --- a/src/AdvancedGUI/Makefile.am +++ b/src/AdvancedGUI/Makefile.am @@ -15,14 +15,13 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# # File : Makefile.am # Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) -# + include $(top_srcdir)/adm_local/unix/make_common_starter.am -# header files +# header files salomeinclude_HEADERS = \ AdvancedGUI.h @@ -65,6 +64,13 @@ MOC_FILES += $(ADVANCED_MOC_FILES) nodist_libAdvancedGUI_la_SOURCES = \ $(MOC_FILES) +# resources files +nodist_salomeres_DATA = \ + AdvancedGUI_images.qm \ + AdvancedGUI_msg_en.qm \ + AdvancedGUI_msg_fr.qm \ + AdvancedGUI_msg_ja.qm + # additional information to compile and link file libAdvancedGUI_la_CPPFLAGS = \ diff --git a/src/GEOMGUI/GEOMGUI_XmlHandler.cxx b/src/GEOMGUI/GEOMGUI_XmlHandler.cxx new file mode 100644 index 000000000..27106bc4c --- /dev/null +++ b/src/GEOMGUI/GEOMGUI_XmlHandler.cxx @@ -0,0 +1,157 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com + +// GEOM GEOMGUI : reading of xml file with list of available plugin actions +// File : GEOMGUI_XmlHandler.cxx +// Author : Julia DOROVSKIKH, Open CASCADE S.A.S. + +#include "GEOMGUI_XmlHandler.h" + +#include "GEOMGUI.h" + +// SALOME KERNEL includes +#include + +/*! + * Constructor + */ +GEOMGUI_XmlHandler::GEOMGUI_XmlHandler() +{ +} + +/*! + * Destructor + */ +GEOMGUI_XmlHandler::~GEOMGUI_XmlHandler() +{ +} + +/*! + * Starts parsing of document. Does some initialization + * + * Reimplemented from QXmlDefaultHandler. + */ +bool GEOMGUI_XmlHandler::startDocument() +{ + myErrorProt = ""; + return true; +} + +/*! + * Does different actions depending on the name of the tag and the + * state you are in document. + * + * Reimplemented from QXmlDefaultHandler. + */ +bool GEOMGUI_XmlHandler::startElement (const QString&, const QString&, + const QString& qName, + const QXmlAttributes& atts) +{ + if (qName == "geom-plugins") { // set of plugins + //myHypothesesMap.clear(); + //myAlgorithmsMap.clear(); + } + else if (qName == "geom-plugin") { // group of actions + myPluginData.myName = atts.value("name"); + myPluginData.myServerLib = atts.value("server-lib"); + myPluginData.myClientLib = atts.value("gui-lib"); + + //QString aResName = atts.value("resources"); + //if (aResName != "") { + // SUIT_ResourceMgr* resMgr = GEOMGUI::resourceMgr(); + // QString lang = resMgr->stringValue( resMgr->langSection(), "language", "en" ); + // resMgr->loadTranslator( "resources", QString( "%1_msg_%2.qm" ).arg( aResName, lang ) ); + // resMgr->loadTranslator( "resources", QString( "%1_images.qm" ).arg( aResName, lang ) ); + //} + } + else if (qName == "actions") { // group of actions + } + else if (qName == "action") { // an action + GEOMGUI_ActionData aData; + aData.myLabel = atts.value("label"); + aData.myIcon = atts.value("icon"); + aData.myMenu = atts.value("menu"); + aData.myTooltip = atts.value("tooltip"); + aData.myStatusBar = atts.value("status-bar"); + + myPluginData.myListOfActions.append(aData); + } + else { + // error + return false; + } + return true; +} + +/*! + * Reimplemented from QXmlDefaultHandler. + */ +bool GEOMGUI_XmlHandler::endElement (const QString&, const QString&, const QString&) +{ + return true; +} + +/*! + * Reimplemented from QXmlDefaultHandler. + */ +bool GEOMGUI_XmlHandler::characters (const QString& ch) +{ + // we are not interested in whitespaces + //QString ch_simplified = ch.simplified(); + //if ( ch_simplified.isEmpty() ) + // return true; + return true; +} + +/*! + * Returns the default error string. + * + * Reimplemented from QXmlDefaultHandler. + */ +QString GEOMGUI_XmlHandler::errorString() +{ + return "the document is not in the quote file format"; +} + +/*! + * Returns the error protocol if parsing failed + * + * Reimplemented from QXmlDefaultHandler. + */ +QString GEOMGUI_XmlHandler::errorProtocol() +{ + return myErrorProt; +} + +/*! + * Returns exception + * + * Reimplemented from QXmlDefaultHandler. + */ +bool GEOMGUI_XmlHandler::fatalError (const QXmlParseException& exception) +{ + myErrorProt += QString("fatal parsing error: %1 in line %2, column %3\n") + .arg(exception.message()) + .arg(exception.lineNumber()) + .arg(exception.columnNumber()); + + return QXmlDefaultHandler::fatalError( exception ); +} diff --git a/src/GEOMGUI/GEOMGUI_XmlHandler.h b/src/GEOMGUI/GEOMGUI_XmlHandler.h new file mode 100644 index 000000000..c1808bca0 --- /dev/null +++ b/src/GEOMGUI/GEOMGUI_XmlHandler.h @@ -0,0 +1,90 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// GEOM GEOMGUI : reading of xml file with list of available plugin actions +// File : GEOMGUI_XmlHandler.h +// Author : Julia DOROVSKIKH, Open CASCADE S.A.S. + +#ifndef GEOMGUI_XMLHANDLER_H +#define GEOMGUI_XMLHANDLER_H + +// GEOM includes +#include "GEOMGUI.h" + +// Qt includes +#include +#include +#include + +//GUI includes +#include + +//class HypothesisData; +//class HypothesesSet; + +struct GEOMGUI_ActionData +{ + QString myLabel; // unique ID + QString myIcon; + QString myMenu; + QString myTooltip; + QString myStatusBar; + + //int myAccel; + //bool myToggle; + //QString myShortcut; +}; + +struct GEOMGUI_PluginData +{ + QString myName; + QString myServerLib; + QString myClientLib; + + //QList myListOfActions; + QList myListOfActions; +}; + +class GEOMGUI_EXPORT GEOMGUI_XmlHandler : public QXmlDefaultHandler +{ +public: + GEOMGUI_XmlHandler(); + virtual ~GEOMGUI_XmlHandler(); + + bool startDocument(); + bool startElement( const QString&, const QString&, + const QString&, const QXmlAttributes& ); + bool endElement( const QString&, const QString&, const QString& ); + bool characters( const QString& ); + + QString errorString(); + QString errorProtocol(); + bool fatalError( const QXmlParseException& ); + +public: + GEOMGUI_PluginData myPluginData; + +private: + QString myErrorProt; +}; + +#endif // GEOMGUI_XMLHANDLER_H diff --git a/src/GEOMGUI/GEOMPluginGUI.cxx b/src/GEOMGUI/GEOMPluginGUI.cxx new file mode 100644 index 000000000..1ba093a84 --- /dev/null +++ b/src/GEOMGUI/GEOMPluginGUI.cxx @@ -0,0 +1,54 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com + +// GEOM GEOMGUI : GUI for Geometry component +// File : GEOMPluginGUI.cxx + +#include "GEOMPluginGUI.h" +#include "GeometryGUI.h" + +#include + +//================================================================================= +// function : GEOMPluginGUI::GEOMPluginGUI +// purpose : Constructor +//================================================================================= +GEOMPluginGUI::GEOMPluginGUI (GeometryGUI* parent) + : GEOMGUI (parent) +{ +} + +//================================================================================= +// function : GEOMPluginGUI::~GEOMPluginGUI +// purpose : Destructor +//================================================================================= +GEOMPluginGUI::~GEOMPluginGUI() +{ +} + +//================================================================================= +// class : GEOMPluginGUI::OnGUIEvent +// purpose : Main/popup menu events processing +//================================================================================= +bool GEOMPluginGUI::OnGUIEvent (const QString& /*action*/, SUIT_Desktop* /*parent*/) +{ + return true; +} diff --git a/src/GEOMGUI/GEOMPluginGUI.h b/src/GEOMGUI/GEOMPluginGUI.h new file mode 100644 index 000000000..537dd6c47 --- /dev/null +++ b/src/GEOMGUI/GEOMPluginGUI.h @@ -0,0 +1,49 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com + +// GEOM GEOMGUI : GUI for Geometry component +// File : GEOMPluginGUI.h + +#ifndef GEOMPLUGINGUI_H +#define GEOMPLUGINGUI_H + +#include "GEOMGUI.h" + +#include + +//================================================================================= +// class : GEOMPluginGUI +// purpose : Base class for all geometry Plugins +//================================================================================= +class GEOMGUI_EXPORT GEOMPluginGUI : public GEOMGUI +{ +public : + // Constructor + GEOMPluginGUI (GeometryGUI* parent); + // Destructor + virtual ~GEOMPluginGUI(); + + //! Parameter action specifies the operation ID + virtual bool OnGUIEvent (const QString& action, SUIT_Desktop* parent); + //virtual bool OnGUIEvent (const QString& action, SUIT_Desktop* parent, const QVariant& theParam); +}; + +#endif // GEOMPluginGUI_H diff --git a/src/GEOMGUI/GEOM_images.ts b/src/GEOMGUI/GEOM_images.ts index 667c07514..853507205 100644 --- a/src/GEOMGUI/GEOM_images.ts +++ b/src/GEOMGUI/GEOM_images.ts @@ -1211,171 +1211,5 @@ ICON_DLG_SCALE_ALONG_AXES scale_along_axes.png - - ICON_DLG_PIPETSHAPE - pipetshape.png - - - ICO_PIPETSHAPE - pipetshape.png - - - ICO_PIPETSHAPE_IMPORT - pipetshape_import_icon.png - - - DLG_PIPETSHAPE - dlg_pipetshape.png - - - IMG_PIPETSHAPE_SECT - pipetshape_section.png - - - DLG_PIPETSHAPE_L1 - dlg_pipetshapel1.png - - - DLG_PIPETSHAPE_R1 - dlg_pipetshaper1.png - - - DLG_PIPETSHAPE_W1 - dlg_pipetshapew1.png - - - DLG_PIPETSHAPE_L2 - dlg_pipetshapel2.png - - - DLG_PIPETSHAPE_R2 - dlg_pipetshaper2.png - - - DLG_PIPETSHAPE_W2 - dlg_pipetshapew2.png - - - - DLG_PIPETSHAPE_FILLET - dlg_pipetshapefillet.png - - - DLG_PIPETSHAPE_FILLET_L1 - dlg_pipetshapefilletl1.png - - - DLG_PIPETSHAPE_FILLET_R1 - dlg_pipetshapefilletr1.png - - - DLG_PIPETSHAPE_FILLET_W1 - dlg_pipetshapefilletw1.png - - - DLG_PIPETSHAPE_FILLET_L2 - dlg_pipetshapefilletl2.png - - - DLG_PIPETSHAPE_FILLET_R2 - dlg_pipetshapefilletr2.png - - - DLG_PIPETSHAPE_FILLET_W2 - dlg_pipetshapefilletw2.png - - - DLG_PIPETSHAPE_FILLET_RF - dlg_pipetshapefilletrf.png - - - - DLG_PIPETSHAPE_CHAMFER - dlg_pipetshapechamfer.png - - - DLG_PIPETSHAPE_CHAMFER_L1 - dlg_pipetshapechamferl1.png - - - DLG_PIPETSHAPE_CHAMFER_R1 - dlg_pipetshapechamferr1.png - - - DLG_PIPETSHAPE_CHAMFER_W1 - dlg_pipetshapechamferw1.png - - - DLG_PIPETSHAPE_CHAMFER_L2 - dlg_pipetshapechamferl2.png - - - DLG_PIPETSHAPE_CHAMFER_R2 - dlg_pipetshapechamferr2.png - - - DLG_PIPETSHAPE_CHAMFER_W2 - dlg_pipetshapechamferw2.png - - - DLG_PIPETSHAPE_CHAMFER_H - dlg_pipetshapechamferh.png - - - DLG_PIPETSHAPE_CHAMFER_W - dlg_pipetshapechamferw.png - - - - ICON_OBJBROWSER_ADVANCED_201 - tree_pipetshape.png - - - - ICON_DLG_DIVIDEDDISK_R_RATIO - divided_disk.png - - - ICO_DIVIDEDDISK - divided_disk.png - - - ICON_OBJBROWSER_ADVANCED_202 - divided_disk.png - - - ICON_DLG_DIVIDEDCYLINDER_R_H - dividedcylinder_r_h.png - - - ICO_DIVIDEDCYLINDER - dividedcylinder.png - - - ICON_OBJBROWSER_ADVANCED_203 - dividedcylinder.png - - - ICON_DLG_SMOOTHINGSURFACE_LPOINTS - smoothingsurface_lpoints.png - - - ICO_SMOOTHINGSURFACE - smoothingsurface.png - - - ICON_OBJBROWSER_ADVANCED_204 - tree_smoothingsurface.png - - diff --git a/src/GEOMGUI/GEOM_msg_en.ts b/src/GEOMGUI/GEOM_msg_en.ts index 8ca73f466..c11b96858 100644 --- a/src/GEOMGUI/GEOM_msg_en.ts +++ b/src/GEOMGUI/GEOM_msg_en.ts @@ -559,22 +559,6 @@ Please, select face, shell or solid and try again GEOM_DIVIDE_EDGE_TITLE Addition of point - - GEOM_DIVIDEDDISK - Divided Disk - - - GEOM_DIVIDEDDISK_TITLE - Divided Disk construction - - - GEOM_DIVIDEDCYLINDER - Divided Cylinder - - - GEOM_DIVIDEDCYLINDER_TITLE - Divided Cylinder construction - GEOM_DX Dx : @@ -2496,30 +2480,6 @@ Please, select face, shell or solid and try again MEN_DISK Disk - - MEN_DIVIDEDDISK - Divided Disk - - - TOP_DIVIDEDDISK - Divided Disk - - - STB_DIVIDEDDISK - Divided Disk - - - MEN_DIVIDEDCYLINDER - Divided Cylinder - - - TOP_DIVIDEDCYLINDER - Divided Cylinder - - - STB_DIVIDEDCYLINDER - Divided Cylinder - MEN_DISPLAY_ALL Show All @@ -4892,87 +4852,11 @@ shells and solids on the other hand. Take into account the units (%1) embedded to the file? Ignoring units will cause model scaling (as dimensions are supposed to be specified in meters). - - GEOM_ADVANCED - Advanced shape: type %1 - - - GEOM_ADVANCED_202 - Divided Disk - - - GEOM_ADVANCED_203 - Divided Cylinder - GEOM_PRECISION_HINT Input value precision can be adjusted using '%1' parameter in Geometry module preferences. - - TOP_PIPETSHAPE - Create Pipe TShape - - - MEN_PIPETSHAPE - Pipe TShape - - - STB_PIPETSHAPE - Create new Pipe TShape object - - - GEOM_ADVANCED_201 - Pipe TShape - - - HALF_LENGTH_MAIN_PIPE - Main pipe half length - - - HALF_LENGTH_INCIDENT_PIPE - Incident pipe half length - - - CIRCULAR_QUARTER_PIPE - Circular quarter of pipe - - - THICKNESS - Thickness - - - FLANGE - Flange - - - CHAMFER_OR_FILLET - Chamfer or fillet - - - CHAMFER - Chamfer - - - FILLET - Fillet - - - JUNCTION_FACE_1 - Junction 1 - - - JUNCTION_FACE_2 - Junction 2 - - - JUNCTION_FACE_3 - Junction 3 - - - INTERNAL_FACES - Internal faces - GEOM_PLUGINS_OTHER Other @@ -4993,14 +4877,6 @@ Ignoring units will cause model scaling (as dimensions are supposed to be specif TOP_SMOOTHINGSURFACE Smoothing Surface - - MEN_SMOOTHINGSURFACE - Smoothing Surface - - - STB_SMOOTHINGSURFACE - Smoothing Surface - GEOM_SELECT_IMAGE Select image... @@ -5823,144 +5699,6 @@ Do you want to create new material? Shared_%1 - - AdvancedGUI_PipeTShapeDlg - - GEOM_PIPE_TSHAPE_TITLE - Pipe TShape Construction - - - GEOM_PIPE_TSHAPE - PipeTShape - - - GEOM_PIPE_TSHAPE_MPIPE - Main pipe - - - GEOM_PIPE_TSHAPE_R - Radius - - - GEOM_PIPE_TSHAPE_W - Width - - - GEOM_PIPE_TSHAPE_L - Half-length - - - GEOM_PIPE_TSHAPE_IPIPE - Incident pipe - - - GEOM_PIPE_TSHAPE_CHAMFER - Chamfer - - - GEOM_PIPE_TSHAPE_CHAMFER_H - Height - - - GEOM_PIPE_TSHAPE_CHAMFER_W - Width - - - GEOM_PIPE_TSHAPE_FILLET - Fillet - - - GEOM_PIPE_TSHAPE_HEX - Prepare for hex mesh - - - GEOM_PIPE_TSHAPE_POSITION - Set position - - - GEOM_PIPE_TSHAPE_POSITION_P1 - Junction P1 - - - GEOM_PIPE_TSHAPE_POSITION_P2 - Junction P2 - - - GEOM_PIPE_TSHAPE_POSITION_P3 - Junction P3 - - - GEOM_PIPE_TSHAPE_POSITION_LBL_L1 - New L1 - - - GEOM_PIPE_TSHAPE_POSITION_LBL_L2 - New L2 - - - GEOM_PIPE_TSHAPE_LEFT_TR - Left thickness reduction - - - GEOM_PIPE_TSHAPE_RIGHT_TR - Right thickness reduction - - - GEOM_PIPE_TSHAPE_INCI_TR - Incident pipe thickness reduction - - - GEOM_PIPE_TSHAPE_TR_R - Radius (r%1) - - - GEOM_PIPE_TSHAPE_TR_W - Width (w%1) - - - GEOM_PIPE_TSHAPE_TR_L_TRANS - Transition length (ltrans%1) - - - GEOM_PIPE_TSHAPE_TR_L_THIN - Thin part length (lthin%1) - - - GEOM_PIPETSHAPE_GROUPMAIN - Main parameters - - - GEOM_PIPETSHAPE_GROUPREDUCT - Thickness reduction - - - GEOM_PIPETSHAPE_GROUPPOS - Position - - - - AdvancedGUI_SmoothingSurfaceDlg - - GEOM_SMOOTHINGSURFACE_TITLE - Smoothing surface Construction - - - GEOM_SMOOTHINGSURFACE - Smoothing surface - - - GEOM_SMOOTHINGSURFACE_RESULT - Result name - - - GEOM_SMOOTHINGSURFACE_ARG - Nodes - - - GEOM_SMOOTHINGSURFACE_ARG_POINTS - Points - - GEOMToolsGUI_PublishDlg diff --git a/src/GEOMGUI/GEOM_msg_fr.ts b/src/GEOMGUI/GEOM_msg_fr.ts index fa0c70000..11bde0082 100644 --- a/src/GEOMGUI/GEOM_msg_fr.ts +++ b/src/GEOMGUI/GEOM_msg_fr.ts @@ -565,22 +565,6 @@ Choisissez une face, une coque ou un solide et essayez de nouveau GEOM_DIVIDE_EDGE_TITLE Ajouter un point - - GEOM_DIVIDEDDISK - Disque prédécoupé - - - GEOM_DIVIDEDDISK_TITLE - Construction d'un disque prédécoupé - - - GEOM_DIVIDEDCYLINDER - Cylinder prédécoupé - - - GEOM_DIVIDEDCYLINDER_TITLE - Construction d'un cylindre prédécoupé - GEOM_DX Dx : @@ -2502,30 +2486,6 @@ Choisissez une face, une coque ou un solide et essayez de nouveau MEN_DISK Disque - - MEN_DIVIDEDDISK - Disque prédécoupé - - - TOP_DIVIDEDDISK - Disque prédécoupé - - - STB_DIVIDEDDISK - Disque prédécoupé - - - MEN_DIVIDEDCYLINDER - Cylinder prédécoupé - - - TOP_DIVIDEDCYLINDER - Cylinder prédécoupé - - - STB_DIVIDEDCYLINDER - Cylinder prédécoupé - MEN_DISPLAY_ALL Afficher tout @@ -4898,87 +4858,11 @@ les coques et solides d'un autre. Voulez-vous prendre les unités du fichier (%1) en considération? Sinon le modèle sera mis à l'échelle GEOM (unités interprétées comme des mètres). - - GEOM_ADVANCED - Objet géométrique avancé : type %1 - - - GEOM_ADVANCED_202 - Disque prédécoupé - - - GEOM_ADVANCED_203 - Cylindre prédécoupé - GEOM_PRECISION_HINT Il est possible d'ajuster la précision de la valeur d'entrée avec le paramètre '%1' aux préférences du module Géométrie. - - TOP_PIPETSHAPE - Créer un tuyau en T - - - MEN_PIPETSHAPE - Tuyau en T - - - STB_PIPETSHAPE - Créer un tuyau en T - - - GEOM_ADVANCED_201 - Tuyau en T - - - HALF_LENGTH_MAIN_PIPE - Demi-longueur du tuyau principal - - - HALF_LENGTH_INCIDENT_PIPE - Demi-longueur du tuyau incident - - - CIRCULAR_QUARTER_PIPE - Un quart circulaire du tuyau - - - THICKNESS - Epaisseur - - - FLANGE - Collerette - - - CHAMFER_OR_FILLET - Chanfrein ou congé - - - CHAMFER - Chanfrein - - - FILLET - Congé - - - JUNCTION_FACE_1 - Jonction 1 - - - JUNCTION_FACE_2 - Jonction 2 - - - JUNCTION_FACE_3 - Jonction 3 - - - INTERNAL_FACES - Internal faces - GEOM_PLUGINS_OTHER Autre @@ -5829,144 +5713,6 @@ Voulez-vous en créer un nouveau ? Partagé_%1 - - AdvancedGUI_PipeTShapeDlg - - GEOM_PIPE_TSHAPE_TITLE - Construction d'un tuyau en T - - - GEOM_PIPE_TSHAPE - Tuyau en T - - - GEOM_PIPE_TSHAPE_MPIPE - Tuyau principal - - - GEOM_PIPE_TSHAPE_R - Rayon - - - GEOM_PIPE_TSHAPE_W - Largeur - - - GEOM_PIPE_TSHAPE_L - Demi-longueur - - - GEOM_PIPE_TSHAPE_IPIPE - Tuyau incident - - - GEOM_PIPE_TSHAPE_CHAMFER - Chanfrein - - - GEOM_PIPE_TSHAPE_CHAMFER_H - Hauteur - - - GEOM_PIPE_TSHAPE_CHAMFER_W - Largeur - - - GEOM_PIPE_TSHAPE_FILLET - Congé - - - GEOM_PIPE_TSHAPE_HEX - Préparer pour un maillage hexaédrique - - - GEOM_PIPE_TSHAPE_POSITION - Définir la position - - - GEOM_PIPE_TSHAPE_POSITION_P1 - Jonction P1 - - - GEOM_PIPE_TSHAPE_POSITION_P2 - Jonction P2 - - - GEOM_PIPE_TSHAPE_POSITION_P3 - Jonction P3 - - - GEOM_PIPE_TSHAPE_POSITION_LBL_L1 - Nouvelle L1 - - - GEOM_PIPE_TSHAPE_POSITION_LBL_L2 - Nouvelle L2 - - - GEOM_PIPE_TSHAPE_LEFT_TR - Réduction d'épaisseur à gauche - - - GEOM_PIPE_TSHAPE_RIGHT_TR - Réduction d'épaisseur à droite - - - GEOM_PIPE_TSHAPE_INCI_TR - Réduction d'épaisseur du tuyau incident - - - GEOM_PIPE_TSHAPE_TR_R - Rayon (r%1) - - - GEOM_PIPE_TSHAPE_TR_W - Epaisseur (w%1) - - - GEOM_PIPE_TSHAPE_TR_L_TRANS - Longueur de transition (ltrans%1) - - - GEOM_PIPE_TSHAPE_TR_L_THIN - Longueur de la partie étroite (lthin%1) - - - GEOM_PIPETSHAPE_GROUPMAIN - Paramètres principaux - - - GEOM_PIPETSHAPE_GROUPREDUCT - Réduction d'épaisseur - - - GEOM_PIPETSHAPE_GROUPPOS - Position - - - - AdvancedGUI_SmoothingSurfaceDlg - - GEOM_SMOOTHINGSURFACE_TITLE - Constructions de surface lisse - - - GEOM_SMOOTHINGSURFACE - Surface lissee - - - GEOM_SMOOTHINGSURFACE_RESULT - Nom du résultat - - - GEOM_SMOOTHINGSURFACE_ARG - Noeuds - - - GEOM_SMOOTHINGSURFACE_ARG_POINTS - Points - - GEOMToolsGUI_PublishDlg diff --git a/src/GEOMGUI/GEOM_msg_ja.ts b/src/GEOMGUI/GEOM_msg_ja.ts index dfbbdbdb6..cad65b98a 100644 --- a/src/GEOMGUI/GEOM_msg_ja.ts +++ b/src/GEOMGUI/GEOM_msg_ja.ts @@ -551,22 +551,6 @@ GEOM_DIVIDE_EDGE_TITLE ポイントの追加 - - GEOM_DIVIDEDDISK - 分割ディスク - - - GEOM_DIVIDEDDISK_TITLE - 分割ディスク建設 - - - GEOM_DIVIDEDCYLINDER - 分割シリンダー - - - GEOM_DIVIDEDCYLINDER_TITLE - 分割構造 - GEOM_DX Dx: @@ -2459,30 +2443,6 @@ MEN_DISK ディスク - - MEN_DIVIDEDDISK - 分割ディスク - - - TOP_DIVIDEDDISK - 分割ディスク - - - STB_DIVIDEDDISK - 分割ディスク - - - MEN_DIVIDEDCYLINDER - 分割シリンダー - - - TOP_DIVIDEDCYLINDER - 分割シリンダー - - - STB_DIVIDEDCYLINDER - 分割シリンダー - MEN_DISPLAY_ALL すべて表示します。 @@ -4751,82 +4711,10 @@ GEOM_SCALE_DIMENSIONS ユニット (%1) ファイルに埋め込まれたアカウントを考慮か?ユニットを無視することにより、モデルをスケーリング (メートル単位で指定するにはサイズを想定)。 - - GEOM_ADVANCED - 形状を高度な:%1 入力 - - - GEOM_ADVANCED_202 - 分割ディスク - - - GEOM_ADVANCED_203 - 分割シリンダー - GEOM_PRECISION_HINT 入力値の精度は、ジオメトリのモジュール設定に '%1' パラメーターを使用して調整できます。 - - TOP_PIPETSHAPE - TShape パイプを作成します。 - - - MEN_PIPETSHAPE - TShape をパイプします。 - - - STB_PIPETSHAPE - 新しいパイプ TShape オブジェクトを作成します。 - - - GEOM_ADVANCED_201 - TShape をパイプします。 - - - HALF_LENGTH_MAIN_PIPE - 主配管の長さの半分 - - - HALF_LENGTH_INCIDENT_PIPE - インシデント管長さの半分 - - - CIRCULAR_QUARTER_PIPE - 円形の四半期パイプの - - - THICKNESS - 厚 - - - FLANGE - フランジ - - - CHAMFER_OR_FILLET - 面取りまたはフィレット - - - CHAMFER - 面取り - - - FILLET - フィレット - - - JUNCTION_FACE_1 - ジャンクション 1 - - - JUNCTION_FACE_2 - ジャンクション 2 - - - JUNCTION_FACE_3 - ジャンクション 3 - GEOM_PLUGINS_OTHER その他 diff --git a/src/GEOMGUI/GeometryGUI.cxx b/src/GEOMGUI/GeometryGUI.cxx index 10ce0ffee..c18df18ad 100644 --- a/src/GEOMGUI/GeometryGUI.cxx +++ b/src/GEOMGUI/GeometryGUI.cxx @@ -29,6 +29,8 @@ #include "Python.h" #include "GeometryGUI.h" #include "GeometryGUI_Operations.h" +#include "GEOMPluginGUI.h" +#include "GEOMGUI_XmlHandler.h" #include "GEOMGUI_OCCSelector.h" #include "GEOMGUI_Selection.h" #include "GEOMGUI_CreationInfoWdg.h" @@ -82,6 +84,7 @@ #include // External includes +#include #include #include #include @@ -277,6 +280,50 @@ GEOMGUI* GeometryGUI::getLibrary( const QString& libraryName ) return myGUIMap.contains( libraryName ) ? myGUIMap[ libraryName ] : 0; } +//======================================================================= +// function : GeometryGUI::getPluginLibrary() +// purpose : get or load GUI Plugin library by name [ internal ] +//======================================================================= +typedef GEOMPluginGUI* (*PluginLibraryGUI)( GeometryGUI* ); +GEOMPluginGUI* GeometryGUI::getPluginLibrary( const QString& libraryName ) +{ + if ( !myGUIMap.contains( libraryName ) ) { + // try to load library if it is not loaded yet +#ifndef WNT + QString dirs = getenv( "LD_LIBRARY_PATH" ); + QString sep = ":"; +#else + QString dirs = getenv( "PATH" ); + QString sep = ";"; +#endif + if ( !dirs.isEmpty() ) { + QStringList dirList = dirs.split(sep, QString::SkipEmptyParts ); // skip empty entries + QListIterator it( dirList ); it.toBack(); + while ( it.hasPrevious() ) { + QFileInfo fi( Qtx::addSlash( it.previous() ) + libraryName ); + if ( fi.exists() ) { + OSD_SharedLibrary aSharedLibrary( fi.fileName().toLatin1().constData() ); + bool res = aSharedLibrary.DlOpen( OSD_RTLD_LAZY ); + if ( !res ) { + MESSAGE( "Can't open library : " << aSharedLibrary.DlError() ); + continue; // continue search further + } + OSD_Function osdF = aSharedLibrary.DlSymb( "GetLibGUI" ); + if ( osdF != NULL ) { + PluginLibraryGUI func = (GEOMPluginGUI* (*) (GeometryGUI*))osdF; + GEOMPluginGUI* libGUI = (*func)( this ); + if ( libGUI ) { + myGUIMap[ libraryName ] = libGUI; + break; // found and loaded! + } + } + } + } + } + } + return myGUIMap.contains( libraryName ) ? (GEOMPluginGUI*)myGUIMap[ libraryName ] : 0; +} + //======================================================================= // function : GeometryGUI::ActiveWorkingPlane() // purpose : Activate Working Plane View @@ -393,8 +440,10 @@ void GeometryGUI::OnGUIEvent( int id, const QVariant& theParam ) << GEOMOp::OpPointMarker << GEOMOp::OpCreateFolder << GEOMOp::OpSortChildren; - if ( !ViewOCC && !ViewVTK && !NotViewerDependentCommands.contains( id ) ) - return; + if ( !ViewOCC && !ViewVTK && !NotViewerDependentCommands.contains( id ) ) { + // activate OCC viewer + getApp()->getViewManager(OCCViewer_Viewer::Type(), /*create=*/true); + } // fix for IPAL9103, point 2 if ( CORBA::is_nil( GetGeomGen() ) ) { @@ -590,16 +639,45 @@ void GeometryGUI::OnGUIEvent( int id, const QVariant& theParam ) case GEOMOp::OpExplodeBlock: // MENU BLOCKS - EXPLODE ON BLOCKS libName = "BlocksGUI"; break; - case GEOMOp::OpAdvancedNoOp: // NO OPERATION (advanced operations base) - case GEOMOp::OpPipeTShape: // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE -// case GEOMOp::OpPipeTShapeGroups: // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE GROUPS - case GEOMOp::OpDividedDisk: // MENU NEW ENTITY - ADVANCED - DIVIDEDDISK - case GEOMOp::OpDividedCylinder: // MENU NEW ENTITY - ADVANCED - DIVIDEDCYLINDER - case GEOMOp::OpSmoothingSurface: // MENU NEW ENTITY - ADVANCED - SMOOTHINGSURFACE - //@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@// - libName = "AdvancedGUI"; - break; + //case GEOMOp::OpAdvancedNoOp: // NO OPERATION (advanced operations base) + //case GEOMOp::OpPipeTShape: // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE + //case GEOMOp::OpPipeTShapeGroups: // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE GROUPS + //case GEOMOp::OpDividedDisk: // MENU NEW ENTITY - ADVANCED - DIVIDEDDISK + //case GEOMOp::OpDividedCylinder: // MENU NEW ENTITY - ADVANCED - DIVIDEDCYLINDER + //case GEOMOp::OpSmoothingSurface: // MENU NEW ENTITY - ADVANCED - SMOOTHINGSURFACE + //@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@// + //libName = "AdvancedGUI"; + //break; default: + if (myPluginActions.contains(id)) { + libName = myPluginActions[id].first; + + GEOMPluginGUI* library = 0; + if ( !libName.isEmpty() ) { +#ifndef WNT + libName = QString( "lib" ) + libName + ".so"; +#else + libName = libName + ".dll"; +#endif + library = getPluginLibrary( libName ); + } + + // call method of corresponding GUI library + if ( library ) { + //QString action ("%1"); + //action = action.arg(id); + + //if( !theParam.isValid() ) + library->OnGUIEvent( myPluginActions[id].second, desk ); + //else + // library->OnGUIEvent( id, desk, theParam); + } + else + SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_LIB_NOT_FOUND" ), tr( "GEOM_BUT_OK" ) ); + + updateCreationInfo(); + return; + } break; } @@ -626,6 +704,57 @@ void GeometryGUI::OnGUIEvent( int id, const QVariant& theParam ) updateCreationInfo(); } +//================================================================================= +// function : GeometryGUI::activateOperation() +// purpose : +//================================================================================= +bool GeometryGUI::activateOperation( int actionId ) +{ + OnGUIEvent(actionId); + return true; +} + +//================================================================================= +// function : GeometryGUI::activateOperation() +// purpose : +//================================================================================= +bool GeometryGUI::activateOperation( const QString& actionId ) +{ + bool isOk = false; + + int id = actionId.toInt(&isOk); + if (isOk) + OnGUIEvent(id); + + return isOk; +} + +//================================================================================= +// function : GeometryGUI::activateOperation() +// purpose : +//================================================================================= +bool GeometryGUI::activateOperation( const QString& actionId, const QString& plugin ) +{ + bool isOk = false; + + QString pluginLib = plugin; + // TODO: if is a plugin name, find plugin library name + if (myPluginLibs.contains(plugin)) + pluginLib = myPluginLibs[plugin]; + + QMap::iterator actionsIter = myPluginActions.begin(); + for (; actionsIter != myPluginActions.end(); ++actionsIter) { + const PluginAction& anAction = actionsIter.value(); + if (anAction.first == pluginLib && anAction.second == actionId) { + // activate operation + OnGUIEvent(actionsIter.key()); + isOk = true; + } + } + + return isOk; +} + //================================================================================= // function : GeometryGUI::OnKeyPress() // purpose : Called when any key is pressed by user [static] @@ -909,8 +1038,6 @@ void GeometryGUI::initialize( CAM_Application* app ) createGeomAction( GEOMOp::OpCreateFolder, "POP_CREATE_FOLDER" ); createGeomAction( GEOMOp::OpSortChildren, "POP_SORT_CHILD_ITEMS" ); - createGeomAction( GEOMOp::OpPipeTShape, "PIPETSHAPE" ); - // Create actions for increase/decrease transparency shortcuts createGeomAction( GEOMOp::OpIncrTransparency, "", "", 0, false, "Geometry:Increase transparency"); @@ -923,10 +1050,10 @@ void GeometryGUI::initialize( CAM_Application* app ) createGeomAction( GEOMOp::OpDecrNbIsos, "", "", 0, false, "Geometry:Decrease number of isolines"); -// createGeomAction( GEOMOp::OpPipeTShapeGroups, "PIPETSHAPEGROUPS" ); - createGeomAction( GEOMOp::OpDividedDisk, "DIVIDEDDISK" ); - createGeomAction( GEOMOp::OpDividedCylinder, "DIVIDEDCYLINDER" ); - createGeomAction( GEOMOp::OpSmoothingSurface, "SMOOTHINGSURFACE" ); + //createGeomAction( GEOMOp::OpPipeTShape, "PIPETSHAPE" ); + //createGeomAction( GEOMOp::OpDividedDisk, "DIVIDEDDISK" ); + //createGeomAction( GEOMOp::OpDividedCylinder, "DIVIDEDCYLINDER" ); + //createGeomAction( GEOMOp::OpSmoothingSurface, "SMOOTHINGSURFACE" ); //@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@// // ---- create menus -------------------------- @@ -965,7 +1092,7 @@ void GeometryGUI::initialize( CAM_Application* app ) createMenu( GEOMOp::OpCone, primId, -1 ); createMenu( GEOMOp::OpRectangle, primId, -1 ); createMenu( GEOMOp::OpDisk, primId, -1 ); - createMenu( GEOMOp::OpPipeTShape,primId, -1 ); + //createMenu( GEOMOp::OpPipeTShape,primId, -1 ); int genId = createMenu( tr( "MEN_GENERATION" ), newEntId, -1 ); createMenu( GEOMOp::OpPrism, genId, -1 ); @@ -976,9 +1103,9 @@ void GeometryGUI::initialize( CAM_Application* app ) createMenu( GEOMOp::OpPipePath, genId, -1 ); #endif - int advId = createMenu( tr( "MEN_ADVANCED" ), newEntId, -1 ); - createMenu( GEOMOp::OpSmoothingSurface, advId, -1 ); - //@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@// + //int advId = createMenu( tr( "MEN_ADVANCED" ), newEntId, -1 ); + //createMenu( GEOMOp::OpSmoothingSurface, advId, -1 ); + //@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@// createMenu( separator(), newEntId, -1 ); @@ -994,8 +1121,8 @@ void GeometryGUI::initialize( CAM_Application* app ) int blocksId = createMenu( tr( "MEN_BLOCKS" ), newEntId, -1 ); createMenu( GEOMOp::OpQuadFace, blocksId, -1 ); createMenu( GEOMOp::OpHexaSolid, blocksId, -1 ); - createMenu( GEOMOp::OpDividedDisk, blocksId, -1 ); - createMenu( GEOMOp::OpDividedCylinder, blocksId, -1 ); + //createMenu( GEOMOp::OpDividedDisk, blocksId, -1 ); + //createMenu( GEOMOp::OpDividedCylinder, blocksId, -1 ); createMenu( separator(), newEntId, -1 ); @@ -1108,7 +1235,7 @@ void GeometryGUI::initialize( CAM_Application* app ) createMenu( separator(), toolsId, -1 ); createMenu( GEOMOp::OpCheckGeom, toolsId, -1 ); #endif - + createMenu( separator(), toolsId, -1 ); createMenu( GEOMOp::OpMaterialsLibrary, toolsId, -1 ); createMenu( separator(), toolsId, -1 ); @@ -1168,14 +1295,11 @@ void GeometryGUI::initialize( CAM_Application* app ) createTool( GEOMOp::OpCone, primTbId ); createTool( GEOMOp::OpRectangle, primTbId ); createTool( GEOMOp::OpDisk, primTbId ); - createTool( GEOMOp::OpPipeTShape, primTbId ); //rnc - - int blocksTbId = createTool( tr( "TOOL_BLOCKS" ) ); - createTool( GEOMOp::OpDividedDisk, blocksTbId ); - createTool( GEOMOp::OpDividedCylinder, blocksTbId ); + //createTool( GEOMOp::OpPipeTShape, primTbId ); //rnc -// int advancedTbId = createTool( tr( "TOOL_ADVANCED" ) ); //rnc -// createTool( GEOMOp::OpPipeTShape, advancedTbId ); + //int blocksTbId = createTool( tr( "TOOL_BLOCKS" ) ); + //createTool( GEOMOp::OpDividedDisk, blocksTbId ); + //createTool( GEOMOp::OpDividedCylinder, blocksTbId ); int boolTbId = createTool( tr( "TOOL_BOOLEAN" ) ); createTool( GEOMOp::OpFuse, boolTbId ); @@ -1250,12 +1374,12 @@ void GeometryGUI::initialize( CAM_Application* app ) int picturesTbId = createTool( tr( "TOOL_PICTURES" ) ); createTool( GEOMOp::OpPictureImport, picturesTbId ); - #ifdef WITH_OPENCV - createTool( GEOMOp::OpFeatureDetect, picturesTbId ); - #endif +#ifdef WITH_OPENCV + createTool( GEOMOp::OpFeatureDetect, picturesTbId ); +#endif - int advancedTbId = createTool( tr( "TOOL_ADVANCED" ) ); - createTool( GEOMOp::OpSmoothingSurface, advancedTbId ); + //int advancedTbId = createTool( tr( "TOOL_ADVANCED" ) ); + //createTool( GEOMOp::OpSmoothingSurface, advancedTbId ); //@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@// // ---- create popup menus -------------------------- @@ -1316,7 +1440,7 @@ void GeometryGUI::initialize( CAM_Application* app ) mgr->setRule( action( GEOMOp::OpVectors ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule ); mgr->setRule( action( GEOMOp::OpVectors ), clientOCCorVTK + " and isVectorsMode", QtxPopupMgr::ToggleRule ); mgr->insert( separator(), -1, -1 ); // ----------- - + mgr->insert( action( GEOMOp::OpColor ), -1, -1 ); // color mgr->setRule( action( GEOMOp::OpColor ), clientOCCorVTKorOB_AndSomeVisible + " and ($component={'GEOM'})" + "and isPhysicalMaterial=false", QtxPopupMgr::VisibleRule ); mgr->insert( action( GEOMOp::OpTransparency ), -1, -1 ); // transparency @@ -1328,9 +1452,9 @@ void GeometryGUI::initialize( CAM_Application* app ) mgr->insert( action( GEOMOp::OpPointMarker ), -1, -1 ); // point marker //mgr->setRule( action( GEOMOp::OpPointMarker ), QString( "selcount>0 and $typeid in {%1}" ).arg(GEOM_POINT ), QtxPopupMgr::VisibleRule ); mgr->setRule( action( GEOMOp::OpPointMarker ), QString( "selcount>0 and ( $typeid in {%1} or compoundOfVertices=true ) " ).arg(GEOM::VERTEX).arg(GEOM::COMPOUND), QtxPopupMgr::VisibleRule ); - + // material properties - mgr->insert( action( GEOMOp::OpMaterialProperties ), -1, -1 ); + mgr->insert( action( GEOMOp::OpMaterialProperties ), -1, -1 ); mgr->setRule( action( GEOMOp::OpMaterialProperties ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule ); // texture @@ -1424,6 +1548,144 @@ void GeometryGUI::initialize( CAM_Application* app ) QColor c = resMgr->colorValue( "Geometry", "toplevel_color", QColor( 170, 85, 0 ) ); GEOM_AISShape::setTopLevelColor(SalomeApp_Tools::color(c)); } + + // create plugin actions and menus + addPluginActions(); +} + +//======================================================================= +// function : GeometryGUI::addPluginActions() +// purpose : +//======================================================================= +void GeometryGUI::addPluginActions() +{ + // Resource manager + SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); + if (!resMgr) return; + + // Find names of a resource XML files ("GEOMActions.xml" and others); + QString PluginsXml; + char* cenv = getenv("GEOM_PluginsList"); + if (cenv) + PluginsXml.sprintf("%s", cenv); + + QStringList PluginsXmlList = PluginsXml.split(":", QString::SkipEmptyParts); + if (PluginsXmlList.count() == 0) return; + + // get full names of xml files from PluginsXmlList + QStringList xmlFiles; + xmlFiles.append(QDir::home().filePath("CustomGeomPlugins.xml")); // may be inexistent + for (int i = 0; i < PluginsXmlList.count(); i++) { + PluginsXml = PluginsXmlList[ i ]; + + // Find full path to the resource XML file + QString xmlFile = resMgr->path("resources", "GEOM", PluginsXml + ".xml"); + if ( xmlFile.isEmpty() ) // try PLUGIN resources + xmlFile = resMgr->path("resources", PluginsXml, PluginsXml + ".xml"); + if ( !xmlFile.isEmpty() ) + xmlFiles.append( xmlFile ); + } + + // create "Advanced Operations" menu and corresponding toolbar + //int advancedMenuId = createMenu(tr("MEN_ADVANCED"), -1, -1, 10); + //int advancedTbarId = createTool(tr("TOOL_ADVANCED")); + int id = GEOMOp::OpLastOperationID; // TODO? + + // loop on xmlFiles + QString aNoAccessFiles; + for (int i = 0; i < xmlFiles.count(); i++) { + QString xmlFile = xmlFiles[ i ]; + + QFile file (xmlFile); + if (file.exists() && file.open(QIODevice::ReadOnly)) { + file.close(); + + GEOMGUI_XmlHandler* aXmlHandler = new GEOMGUI_XmlHandler(); + ASSERT(aXmlHandler); + + QXmlInputSource source (&file); + QXmlSimpleReader reader; + reader.setContentHandler(aXmlHandler); + reader.setErrorHandler(aXmlHandler); + bool ok = reader.parse(source); + file.close(); + + if (ok) { + // bind action lib and label to its ID for activateOperation() method proper work + myPluginLibs[aXmlHandler->myPluginData.myName] = aXmlHandler->myPluginData.myClientLib; + + QListIterator anActionsIter (aXmlHandler->myPluginData.myListOfActions); + while (anActionsIter.hasNext()) { + GEOMGUI_ActionData anActionData = anActionsIter.next(); + + //QPixmap icon = resMgr->loadPixmap("GEOM", tr(anActionData.myIcon.toLatin1().constData())); + QPixmap icon = resMgr->loadPixmap(aXmlHandler->myPluginData.myName, + anActionData.myIcon.toLatin1().constData()); + + // path to action in menu + QStringList smenus = anActionData.myMenu.split( "/" ); + QString actionName = smenus.last(); + actionName = actionName.toUpper().prepend("MEN_"); + smenus.removeLast(); + + // path to action in toolbar + QStringList stools = anActionData.myTooltip.split( "/" ); + QString actionTool = stools.last(); + actionTool = actionTool.toUpper().prepend("TOP_"); + stools.removeLast(); + + createAction(id, // ~ anActionData.myLabel + tr(actionTool.toLatin1().constData()), + icon, + tr(actionName.toLatin1().constData()), + anActionData.myStatusBar.toLatin1().constData(), + 0 /*accel*/, + application()->desktop(), + false /*toggle*/, + this, SLOT(OnGUIEvent()), + QString() /*shortcutAction*/); + + int menuId = -1; + foreach (QString subMenu, smenus) { + subMenu = subMenu.toUpper().prepend("MEN_"); + menuId = createMenu(tr(subMenu.toLatin1().constData()), menuId, -1); + } + //createMenu(id, pluginMenuId, -1); + createMenu(id, menuId, -1); + + QString subTool = stools[0]; + subTool = subTool.toUpper().prepend("TOOL_"); + int toolId = createTool(tr(subTool.toLatin1().constData())); + //createTool(id, advancedTbarId); + createTool(id, toolId); + + // add action id to map + PluginAction anAction (aXmlHandler->myPluginData.myClientLib, anActionData.myLabel); + myPluginActions[id] = anAction; + + id++; + } + } + else { + SUIT_MessageBox::critical(application()->desktop(), + tr("INF_PARSE_ERROR"), + tr(aXmlHandler->errorProtocol().toLatin1().data())); + } + delete aXmlHandler; + } + else if ( i > 0 ) { // 1st is ~/CustomGeomPlugins.xml + if (aNoAccessFiles.isEmpty()) + aNoAccessFiles = xmlFile; + else + aNoAccessFiles += ", " + xmlFile; + } + } // end loop on xmlFiles + + if (!aNoAccessFiles.isEmpty()) { + QString aMess = QObject::tr("PLUGIN_FILE_CANT_OPEN") + " " + aNoAccessFiles + "\n"; + aMess += QObject::tr("PLUGIN_FILE_CHECK_VARIABLE"); + SUIT_MessageBox::warning(application()->desktop(), tr("GEOM_WRN_WARNING"), aMess); + } } //======================================================================= @@ -1687,13 +1949,14 @@ void GeometryGUI::onViewManagerRemoved( SUIT_ViewManager* vm ) //================================================================================ /*! - * \brief Slot called when selection changed. Shows creation info of a selected object + * \brief Slot called when selection changed. Shows creation info of a selected object */ //================================================================================ void GeometryGUI::updateCreationInfo() { - myCreationInfoWdg->clear(); + if ( myCreationInfoWdg ) + myCreationInfoWdg->clear(); // Code below is commented to have myCreationInfoWdg filled as soon as it is shown again // if ( !myCreationInfoWdg->isVisible() ) @@ -1726,34 +1989,32 @@ void GeometryGUI::updateCreationInfo() // pass creation info of geomObj to myCreationInfoWdg - QPixmap icon; - QString operationName; - myCreationInfoWdg->setOperation( icon, operationName ); - - try - { - OCC_CATCH_SIGNALS; - GEOM::CreationInformation_var info = geomObj->GetCreationInformation(); - if ( &info.in() ) - { - SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); - QString name = info->operationName.in(); - if ( !name.isEmpty() ) - { - icon = resMgr->loadPixmap( "GEOM", tr( ("ICO_"+name).toLatin1().constData() ), false ); - operationName = tr( ("MEN_"+name).toLatin1().constData() ); - if ( operationName.startsWith( "MEN_" )) - operationName = name; // no translation - myCreationInfoWdg->setOperation( icon, operationName ); - - for ( size_t i = 0; i < info->params.length(); ++i ) - myCreationInfoWdg->addParam( info->params[i].name.in(), - info->params[i].value.in() ); + if ( myCreationInfoWdg ) { + QPixmap icon; + QString operationName; + myCreationInfoWdg->setOperation( icon, operationName ); + + try { + OCC_CATCH_SIGNALS; + GEOM::CreationInformation_var info = geomObj->GetCreationInformation(); + if ( &info.in() ) { + SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); + QString name = info->operationName.in(); + if ( !name.isEmpty() ) { + icon = resMgr->loadPixmap( "GEOM", tr( ("ICO_"+name).toLatin1().constData() ), false ); + operationName = tr( ("MEN_"+name).toLatin1().constData() ); + if ( operationName.startsWith( "MEN_" )) + operationName = name; // no translation + myCreationInfoWdg->setOperation( icon, operationName ); + + for ( size_t i = 0; i < info->params.length(); ++i ) + myCreationInfoWdg->addParam( info->params[i].name.in(), + info->params[i].value.in() ); + } } } - } - catch (...) - { + catch (...) { + } } } @@ -1880,7 +2141,7 @@ void GeometryGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& if( isPredefMat ){ QMenu* matMenu = new QMenu(); QSignalMapper* signalMapper = new QSignalMapper( matMenu ); - + //Get current material model for the object QVariant v; LightApp_Application* anApp = dynamic_cast( getApp() ); @@ -1895,13 +2156,13 @@ void GeometryGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& // get list of all predefined materials QStringList materials = Material_ResourceMgr::resourceMgr()->materials(); bool found = false; - foreach ( QString material, materials ) + foreach ( QString material, materials ) { QAction* menAct = matMenu->addAction( material ); connect(menAct, SIGNAL( toggled( bool ) ), signalMapper, SLOT( map() ) ); signalMapper->setMapping( menAct, material ); menAct->setCheckable( true ); - // Set checked if this material is current + // Set checked if this material is current Material_Model aModel; aModel.fromResources( material ); if ( !found && aModel.toProperties() == curModel ) { @@ -2013,15 +2274,15 @@ void GeometryGUI::createPreferences() addPreference( tr( "PREF_AUTO_BRING_TO_FRONT" ), genGroup, LightApp_Preferences::Bool, "Geometry", "auto_bring_to_front" ); - + int isoGroup = addPreference( tr( "PREF_ISOS" ), tabId ); setPreferenceProperty( isoGroup, "columns", 2 ); int isoU = addPreference( tr( "PREF_ISOS_U" ), isoGroup, - LightApp_Preferences::IntSpin, "Geometry", "iso_number_u" ); + LightApp_Preferences::IntSpin, "Geometry", "iso_number_u" ); setPreferenceProperty( isoU, "min", 0 ); setPreferenceProperty( isoU, "max", 100000 ); int isoV = addPreference( tr( "PREF_ISOS_V" ), isoGroup, - LightApp_Preferences::IntSpin, "Geometry", "iso_number_v" ); + LightApp_Preferences::IntSpin, "Geometry", "iso_number_v" ); setPreferenceProperty( isoV, "min", 0 ); setPreferenceProperty( isoV, "max", 100000 ); @@ -2109,7 +2370,7 @@ void GeometryGUI::createPreferences() // Set property for default material setPreferenceProperty( material, "strings", Material_ResourceMgr::resourceMgr()->materials() ); - + // Set property vertex marker type QList aMarkerTypeIndicesList; QList aMarkerTypeIconsList; diff --git a/src/GEOMGUI/GeometryGUI.h b/src/GEOMGUI/GeometryGUI.h index cbef549b6..78eb05db4 100644 --- a/src/GEOMGUI/GeometryGUI.h +++ b/src/GEOMGUI/GeometryGUI.h @@ -38,9 +38,11 @@ #include #include "GEOMGUI.h" +#include "GEOMPluginGUI.h" // QT Includes #include +#include // OCCT Includes #include @@ -113,6 +115,9 @@ public: // Process action void OnGUIEvent( int id, const QVariant& theParam = QVariant( QVariant::Invalid ) ); + virtual bool activateOperation( int actionId ); + virtual bool activateOperation( const QString& actionId ); + virtual bool activateOperation( const QString& actionId, const QString& plugin ); // The Working Plane management void SetWorkingPlane( gp_Ax3 wp ) { myWorkingPlane = wp; } @@ -180,6 +185,7 @@ protected: private: GEOMGUI* getLibrary( const QString& libraryName ); + GEOMPluginGUI* getPluginLibrary( const QString& libraryName ); void createGeomAction( const int id, const QString& po_id, const QString& icon_id = QString(""), const int key = 0, const bool toggle = false, @@ -188,6 +194,7 @@ private: const bool isSingle = false, const int isVisible = -1, const bool isExpandAll = false, const bool isOCC = false, const int parentId = -1 ); + void addPluginActions(); void createOriginAndBaseVectors(); @@ -205,12 +212,17 @@ private: typedef QMap StudyTextureMap; typedef QMap GUIMap; + typedef QPair PluginAction; + GUIMap myGUIMap; // GUI libraries map QDialog* myActiveDialogBox; // active dialog box gp_Ax3 myWorkingPlane; - QMap myRules; // popup rules + //QMap myRules; // popup rules static StudyTextureMap myTextureMap; // texture map + QMap myPluginActions; // plugin actions + QMap myPluginLibs; // plugin name to plugin client library + QList myOCCSelectors; QList myVTKSelectors; diff --git a/src/GEOMGUI/GeometryGUI_Operations.h b/src/GEOMGUI/GeometryGUI_Operations.h index 38fa6d57f..86963a94b 100644 --- a/src/GEOMGUI/GeometryGUI_Operations.h +++ b/src/GEOMGUI/GeometryGUI_Operations.h @@ -195,12 +195,13 @@ namespace GEOMOp { OpExplodeBlock = 6104, // MENU BLOCKS - EXPLODE ON BLOCKS // AdvancedGUI -----------------//-------------------------------- OpAdvancedNoOp = 10000, // NO OPERATION (advanced operations base) - OpPipeTShape = 10001, // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE - //OpPipeTShapeGroups = 10002, // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE GROUPS - OpDividedDisk = 10003, // MENU NEW ENTITY - ADVANCED - DIVIDEDDISK - OpDividedCylinder = 10004, // MENU NEW ENTITY - ADVANCED - DIVIDEDCYLINDER - OpSmoothingSurface = 10005, // MENU NEW ENTITY - ADVANCED - SMOOTHINGSURFACE + //OpPipeTShape = 10001, // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE + //OpPipeTShapeGroups = 10002, // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE GROUPS + //OpDividedDisk = 10003, // MENU NEW ENTITY - ADVANCED - DIVIDEDDISK + //OpDividedCylinder = 10004, // MENU NEW ENTITY - ADVANCED - DIVIDEDCYLINDER + //OpSmoothingSurface = 10005, // MENU NEW ENTITY - ADVANCED - SMOOTHINGSURFACE //@@ insert new functions before this line @@ do not remove this line @@// + OpLastOperationID = 20000 // DO NOT USE OPERATION IDs MORE THAN 20000 !!! }; } diff --git a/src/GEOMGUI/Makefile.am b/src/GEOMGUI/Makefile.am index 54f6e94fb..c476494dd 100644 --- a/src/GEOMGUI/Makefile.am +++ b/src/GEOMGUI/Makefile.am @@ -32,6 +32,8 @@ salomeinclude_HEADERS = \ GeometryGUI.h \ GeometryGUI_Operations.h\ GEOMGUI.h \ + GEOMPluginGUI.h \ + GEOMGUI_XmlHandler.h \ GEOM_Displayer.h \ GEOMGUI_OCCSelector.h \ GEOMGUI_Selection.h \ @@ -41,6 +43,8 @@ salomeinclude_HEADERS = \ dist_libGEOM_la_SOURCES = \ GeometryGUI.cxx \ GEOMGUI.cxx \ + GEOMPluginGUI.cxx \ + GEOMGUI_XmlHandler.cxx \ GEOM_Displayer.cxx \ GEOMGUI_OCCSelector.cxx \ GEOMGUI_Selection.cxx \ diff --git a/src/GEOMImpl/GEOMImpl_DividedDiskDriver.cxx b/src/GEOMImpl/GEOMImpl_DividedDiskDriver.cxx deleted file mode 100644 index 8a756d56c..000000000 --- a/src/GEOMImpl/GEOMImpl_DividedDiskDriver.cxx +++ /dev/null @@ -1,527 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include - -#include -#include -#include -#include - -// OCCT includes -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include -#include - -#include - -#include -//@@ include required header files here @@// - -enum -{ - SQUARE, - HEXAGON -}; -//======================================================================= -//function : GetID -//purpose : -//======================================================================= -const Standard_GUID& GEOMImpl_DividedDiskDriver::GetID() -{ - static Standard_GUID aGUID("0b01da9a-c5da-11e1-8d80-78e7d1879630"); - return aGUID; -} - -//======================================================================= -//function : GEOMImpl_DividedDiskDriver -//purpose : -//======================================================================= -GEOMImpl_DividedDiskDriver::GEOMImpl_DividedDiskDriver() -{ -} - -//======================================================================= -//function : Execute -//purpose : -//======================================================================= -Standard_Integer GEOMImpl_DividedDiskDriver::Execute(TFunction_Logbook& log) const -{ - if (Label().IsNull()) return 0; - Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); - - GEOMImpl_IDividedDisk aData (aFunction); - Standard_Integer aType = aFunction->GetType(); - - TopoDS_Shape aShape; - - // Getting data - double R = aData.GetR(); - double Ratio = aData.GetRatio(); - int Pattern = aData.GetType(); - - // Build reference disk (in the global coordinate system) - TopoDS_Shape aDisk; - - if (Pattern == SQUARE) - aDisk = MakeDiskSquare( R, Ratio ); - else if (Pattern == HEXAGON) - aDisk = MakeDiskHexagon( R, Ratio ); - - if (aType == DIVIDEDDISK_R_RATIO) - { - int theOrientation = aData.GetOrientation(); - aShape = TransformShape(aDisk, theOrientation); - } - else if (aType == DIVIDEDDISK_R_VECTOR_PNT) - { - Handle(GEOM_Function) aRefPoint = aData.GetCenter(); - Handle(GEOM_Function) aRefVector = aData.GetVector(); - TopoDS_Shape aShapePnt = aRefPoint->GetValue(); - TopoDS_Shape aShapeVec = aRefVector->GetValue(); - - if (aShapePnt.ShapeType() == TopAbs_VERTEX && - aShapeVec.ShapeType() == TopAbs_EDGE) - { - gp_Pnt aPnt = BRep_Tool::Pnt(TopoDS::Vertex(aShapePnt)); - TopoDS_Edge anE = TopoDS::Edge(aShapeVec); - TopoDS_Vertex V1, V2; - TopExp::Vertices(anE, V1, V2, Standard_True); - if (!V1.IsNull() && !V2.IsNull()) - { - gp_Vec aVec (BRep_Tool::Pnt(V1), BRep_Tool::Pnt(V2)); - gp_Dir aDir(aVec); - aShape = TransformShape(aDisk, aPnt, aDir); - } - } - } - - if (aShape.IsNull()) return 0; - - aFunction->SetValue(aShape); - - log.SetTouched(Label()); - - return 1; -} - - -//======================================================================= -//function : MakeDiskHexagon -//purpose : -//======================================================================= -TopoDS_Shell GEOMImpl_DividedDiskDriver::MakeDiskHexagon(double R, double Ratio) const -{ - // Geometry - gp_Dir ZDir(0,0,1); - gp_Dir XDir(1,0,0); - gp_Pnt Orig(0,0,0); - - // Circle - gp_Ax1 Ax1(Orig,ZDir); - gp_Ax2 Ax(Orig,ZDir,XDir); - gp_Circ aCircle(Ax, R); - - // Points -// gp_Pnt P4(0.01*Ratio*R,0,0); -// gp_Pnt P3(R,0,0); -// gp_Pnt P2 = P3.Rotated(Ax1,-M_PI/6.0); -// gp_Pnt P1(P4.X(), -// P4.X()/sqrt(3.0),0); - gp_Pnt P1(0.01*Ratio*R*sqrt(3.0)/2,0,0); - gp_Pnt P2(R,0,0); - gp_Pnt P3 = P2.Rotated(Ax1,M_PI/6.0); - gp_Pnt P4(P1.X(), - P1.X()/sqrt(3.0),0); - - - //surfaces - gp_Ax2 anAx (gp::XOY()); - Handle(Geom_Plane) aPlane = new Geom_Plane (anAx); - - // Topology - - // Vertices - TopoDS_Vertex O = BRepBuilderAPI_MakeVertex(Orig); - TopoDS_Vertex V1_init = BRepBuilderAPI_MakeVertex(P1); - TopoDS_Vertex V2_init = BRepBuilderAPI_MakeVertex(P2); - TopoDS_Vertex V3 = BRepBuilderAPI_MakeVertex(P3); - TopoDS_Vertex V4 = BRepBuilderAPI_MakeVertex(P4); - - TopoDS_Vertex V1 = V1_init; - TopoDS_Vertex V2 = V2_init; - - //Rotation - gp_Trsf myTrsf; - myTrsf.SetRotation(Ax1, M_PI/3.0); - - BRepBuilderAPI_Transform xform(myTrsf); - xform.Perform(V1,Standard_True); - TopoDS_Vertex V1_60 = TopoDS::Vertex(xform.Shape()); - xform.Perform(V2,Standard_True); - TopoDS_Vertex V2_60 = TopoDS::Vertex(xform.Shape()); - - // Declaration of shapes (used in the loop) - TopoDS_Edge E1, E2, E3, E4, E5, E6, E7, E8, E9; - TopoDS_Wire W1, W2, W3; - TopoDS_Face F1, F2, F3; - TopoDS_Shell S; - - BRep_Builder aBuilder; - aBuilder.MakeShell(S); - - // Initialisation of edges - TopoDS_Edge E1_init = BRepBuilderAPI_MakeEdge(V1,TopoDS::Vertex(V2.Reversed())); - E1 = E1_init; - TopoDS_Edge E8_init = BRepBuilderAPI_MakeEdge(O,TopoDS::Vertex(V1.Reversed())); - E8 = E8_init; - - for (int i=1;i<=6;i++) - { - // Edges - - // for Face1 - E2 = BRepBuilderAPI_MakeEdge(aCircle, V2, TopoDS::Vertex(V3.Reversed())); - E3 = BRepBuilderAPI_MakeEdge(V3,TopoDS::Vertex(V4.Reversed())); - E4 = BRepBuilderAPI_MakeEdge(V4,TopoDS::Vertex(V1.Reversed())); - - // for Face2 - if (i==6) - { - E5 = BRepBuilderAPI_MakeEdge(aCircle, V3, TopoDS::Vertex(V2_init.Reversed())); - E7 = BRepBuilderAPI_MakeEdge(V1_init,TopoDS::Vertex(V4.Reversed())); - } - else - { - E5 = BRepBuilderAPI_MakeEdge(aCircle, V3, TopoDS::Vertex(V2_60.Reversed())); - E7 = BRepBuilderAPI_MakeEdge(V1_60,TopoDS::Vertex(V4.Reversed())); - } - E6 = BRepBuilderAPI_MakeEdge(V2_60,TopoDS::Vertex(V1_60.Reversed())); - - // for Face3 - E9 = BRepBuilderAPI_MakeEdge(V1_60,TopoDS::Vertex(O.Reversed())); - - - // Wires - - //Wire1 - aBuilder.MakeWire(W1); - if (i==1) - aBuilder.Add(W1,E1); - else - aBuilder.Add(W1,TopoDS::Edge(E1.Reversed())); - aBuilder.Add(W1,E2); - aBuilder.Add(W1,E3); - aBuilder.Add(W1,E4); - - // Wire 2 - aBuilder.MakeWire(W2); - aBuilder.Add(W2,TopoDS::Edge(E3.Reversed())); - aBuilder.Add(W2,E5); - if (i==6) - aBuilder.Add(W2,TopoDS::Edge(E1_init.Reversed())); - else - aBuilder.Add(W2,E6); - aBuilder.Add(W2,E7); - - // Wire3 - aBuilder.MakeWire(W3); - if (i==1) - aBuilder.Add(W3,E8); - else - aBuilder.Add(W3,TopoDS::Edge(E8.Reversed())); - aBuilder.Add(W3,TopoDS::Edge(E4.Reversed())); - aBuilder.Add(W3,TopoDS::Edge(E7.Reversed())); - if (i==6) - aBuilder.Add(W3,TopoDS::Edge(E8_init.Reversed())); - else - aBuilder.Add(W3,E9); - - // Faces creation - F1 = BRepBuilderAPI_MakeFace(aPlane,W1); - F2 = BRepBuilderAPI_MakeFace(aPlane,W2); - F3 = BRepBuilderAPI_MakeFace(aPlane,W3); - - //Shell - aBuilder.Add(S, F1); - aBuilder.Add(S, F2); - aBuilder.Add(S, F3); - - // rotation - V1=V1_60; - V2=V2_60; - - xform.Perform(V1_60,Standard_True); - V1_60 = TopoDS::Vertex(xform.Shape()); - xform.Perform(V2_60,Standard_True); - V2_60 = TopoDS::Vertex(xform.Shape()); - xform.Perform(V3,Standard_True); - V3 = TopoDS::Vertex(xform.Shape()); - xform.Perform(V4,Standard_True); - V4 = TopoDS::Vertex(xform.Shape()); - - // "Increment" of edges - E1=E6; - E8=E9; - } - - return S; -} - -//======================================================================= -//function : MakeDiskSquare -//purpose : -//======================================================================= -TopoDS_Shape GEOMImpl_DividedDiskDriver::MakeDiskSquare(double R, double Ratio) const -{ - // Geometry - gp_Dir ZDir(0,0,1); - gp_Dir XDir(1,0,0); - gp_Pnt Orig(0,0,0); - - // Circle - gp_Ax1 Ax1(Orig,ZDir); - gp_Ax2 Ax(Orig,ZDir,XDir); - gp_Circ aCircle(Ax, R); - - // Points - gp_Pnt P1(0.01*Ratio*R,0,0); - gp_Pnt P2(R,0,0); - - //surfaces - gp_Ax2 anAx (gp::XOY()); - Handle(Geom_Plane) aPlane = new Geom_Plane (anAx); - - // Topology - - // Vertices - TopoDS_Vertex V1_init = BRepBuilderAPI_MakeVertex(P1); - TopoDS_Vertex V2_init = BRepBuilderAPI_MakeVertex(P2); - - TopoDS_Vertex V1 = V1_init; - TopoDS_Vertex V2 = V2_init; - - //Rotation - gp_Trsf myTrsf; - myTrsf.SetRotation(Ax1, M_PI/2); - - BRepBuilderAPI_Transform xform(myTrsf); - xform.Perform(V1,Standard_True); - TopoDS_Vertex V1_rotated = TopoDS::Vertex(xform.Shape()); - xform.Perform(V2,Standard_True); - TopoDS_Vertex V2_rotated = TopoDS::Vertex(xform.Shape()); - - // Declaration of shapes (used in the loop) - TopoDS_Edge E1, E2, E3, E4; - TopoDS_Wire W1, W2; - TopoDS_Face F1, F2; - TopoDS_Shell S; - - BRep_Builder aBuilder; - aBuilder.MakeWire(W2); // Central Wire - aBuilder.MakeShell(S); // Shell - - // Initialisation of edges - TopoDS_Edge E1_init = BRepBuilderAPI_MakeEdge(V1,TopoDS::Vertex(V2.Reversed())); - E1 = E1_init; - - for (int i=1;i<=4;i++) - { - // Edges - // for Face1 - - E3 = BRepBuilderAPI_MakeEdge(V2_rotated,TopoDS::Vertex(V1_rotated.Reversed())); - if (i == 4) - { - E2 = BRepBuilderAPI_MakeEdge(aCircle, V2, TopoDS::Vertex(V2_init.Reversed())); - E4 = BRepBuilderAPI_MakeEdge(V1_init,TopoDS::Vertex(V1.Reversed())); - } - else - { - E2 = BRepBuilderAPI_MakeEdge(aCircle, V2, TopoDS::Vertex(V2_rotated.Reversed())); - E4 = BRepBuilderAPI_MakeEdge(V1_rotated,TopoDS::Vertex(V1.Reversed())); - } - - // Wires - //Wire1 - aBuilder.MakeWire(W1); - if (i==1) - aBuilder.Add(W1,E1); - else - aBuilder.Add(W1,TopoDS::Edge(E1.Reversed())); - aBuilder.Add(W1,E2); - if (i==4) - aBuilder.Add(W1,TopoDS::Edge(E1_init.Reversed())); - else - aBuilder.Add(W1,E3); - aBuilder.Add(W1,E4); - - // Wire central - aBuilder.Add(W2,TopoDS::Edge(E4.Reversed())); - - // Faces creation - F1 = BRepBuilderAPI_MakeFace(aPlane,W1); - - //Shell - aBuilder.Add(S, F1); - - // rotation - V1=V1_rotated; - V2=V2_rotated; - - xform.Perform(V1_rotated,Standard_True); - V1_rotated = TopoDS::Vertex(xform.Shape()); - xform.Perform(V2_rotated,Standard_True); - V2_rotated = TopoDS::Vertex(xform.Shape()); - - // "Increment" of edges - E1=E3; - } - // Central square Face - F2 = BRepBuilderAPI_MakeFace(aPlane,W2); - aBuilder.Add(S, F2); - - return S; -} - - -//======================================================================= -//function : TrasformShape(TopoDS_Shape aShape,int theOrientation) -//purpose : Perform shape transformation accordingly with specified -// orientation -//======================================================================= -TopoDS_Shape GEOMImpl_DividedDiskDriver::TransformShape(TopoDS_Shape theShape, int theOrientation) const -{ - gp_Dir N, Vx; - gp_Pnt theOrigin = gp::Origin(); - - switch(theOrientation) - { - case 1: - { - N = gp::DZ(); - Vx = gp::DX(); - break; - } - case 2: - { - N = gp::DX(); - Vx = gp::DY(); - break; - } - case 3: - { - N = gp::DY(); - Vx = gp::DZ(); - break; - } - } - - gp_Ax3 aWPlane = gp_Ax3(theOrigin, N, Vx); - - return WPlaneTransform(theShape, aWPlane); -} - -//======================================================================= -//function : TrasformShape(TopoDS_Shape aShape, gp_Dir V, gp_Pnt P) -//purpose : Perform shape transformation accordingly with specified -// pnt and direction -//======================================================================= -TopoDS_Shape GEOMImpl_DividedDiskDriver::TransformShape(TopoDS_Shape theShape, gp_Pnt P, gp_Dir V) const -{ - gp_Ax3 aWPlane( P, V ); - return WPlaneTransform(theShape, aWPlane); -} - -//======================================================================= -//function : WPlaneTransform -//purpose : Perform shape transformation accordingly with the given -// Working Plane -//======================================================================= -TopoDS_Shape GEOMImpl_DividedDiskDriver::WPlaneTransform(TopoDS_Shape theShape, gp_Ax3 theWPlane) const -{ - gp_Trsf aTrans; - aTrans.SetTransformation(theWPlane); - aTrans.Invert(); - BRepBuilderAPI_Transform aTransformation (theShape, aTrans, Standard_False); - return aTransformation.Shape(); -} - -//================================================================================ -/*! - * \brief Returns a name of creation operation and names and values of creation parameters - */ -//================================================================================ - -bool GEOMImpl_DividedDiskDriver:: -GetCreationInformation(std::string& theOperationName, - std::vector& theParams) -{ - if (Label().IsNull()) return 0; - Handle(GEOM_Function) function = GEOM_Function::GetFunction(Label()); - - GEOMImpl_IDividedDisk aCI( function ); - Standard_Integer aType = function->GetType(); - - theOperationName = "DIVIDEDDISK"; - - switch ( aType ) { - case DIVIDEDDISK_R_RATIO: - AddParam( theParams, "Radius", aCI.GetR() ); - AddParam( theParams, "Ratio", aCI.GetRatio() ); - AddParam( theParams, "Orientation", aCI.GetOrientation() ); - AddParam( theParams, "Division pattern", aCI.GetType() ); - break; - case DIVIDEDDISK_R_VECTOR_PNT: - AddParam( theParams, "Center Point", aCI.GetCenter() ); - AddParam( theParams, "Vector", aCI.GetVector() ); - AddParam( theParams, "Radius", aCI.GetR() ); - AddParam( theParams, "Division pattern", aCI.GetType() ); - break; - default: - return false; - } - - return true; -} - -IMPLEMENT_STANDARD_HANDLE (GEOMImpl_DividedDiskDriver,GEOM_BaseDriver); -IMPLEMENT_STANDARD_RTTIEXT (GEOMImpl_DividedDiskDriver,GEOM_BaseDriver); diff --git a/src/GEOMImpl/GEOMImpl_DividedDiskDriver.hxx b/src/GEOMImpl/GEOMImpl_DividedDiskDriver.hxx deleted file mode 100644 index 8f6755a80..000000000 --- a/src/GEOMImpl/GEOMImpl_DividedDiskDriver.hxx +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef _GEOMImpl_DividedDiskDriver_HXX -#define _GEOMImpl_DividedDiskDriver_HXX - -#include - -class Handle_Standard_Type; -class GEOMImpl_DividedDiskDriver; -class TopoDS_Shape; -class TopoDS_Shell; -class gp_Pnt; -class gp_Dir; -class gp_Ax3; - -#include "GEOM_BaseDriver.hxx" - -DEFINE_STANDARD_HANDLE( GEOMImpl_DividedDiskDriver, GEOM_BaseDriver ); - -class GEOMImpl_DividedDiskDriver : public GEOM_BaseDriver { -public: - // Methods PUBLIC - // - Standard_EXPORT GEOMImpl_DividedDiskDriver(); - Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const; - Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {} - Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const - { - return Standard_True; - } - Standard_EXPORT static const Standard_GUID& GetID(); - Standard_EXPORT ~GEOMImpl_DividedDiskDriver() {}; - - Standard_EXPORT virtual - bool GetCreationInformation(std::string& theOperationName, - std::vector& params); -private: - TopoDS_Shape TransformShape (TopoDS_Shape aShape, int theOrientation) const; - TopoDS_Shape TransformShape (TopoDS_Shape aShape, gp_Pnt P, gp_Dir V) const; - TopoDS_Shape WPlaneTransform (TopoDS_Shape aShape, gp_Ax3 theWPlane) const; - TopoDS_Shell MakeDiskHexagon (double R, double Ratio) const; - TopoDS_Shape MakeDiskSquare (double R, double Ratio) const; - - DEFINE_STANDARD_RTTI( GEOMImpl_DividedDiskDriver ) -}; - -#endif // _GEOMImpl_DividedDiskDriver_HXX diff --git a/src/GEOMImpl/GEOMImpl_Gen.cxx b/src/GEOMImpl/GEOMImpl_Gen.cxx index 9de130a4a..4b91160ba 100644 --- a/src/GEOMImpl/GEOMImpl_Gen.cxx +++ b/src/GEOMImpl/GEOMImpl_Gen.cxx @@ -82,12 +82,6 @@ #include #include #include -// Advanced operations -#include -#include -// #include -#include -/*@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@*/ //============================================================================= /*! @@ -169,13 +163,6 @@ GEOMImpl_Gen::GEOMImpl_Gen() // Measurements TFunction_DriverTable::Get()->AddDriver(GEOMImpl_MeasureDriver::GetID(), new GEOMImpl_MeasureDriver()); - // Advanced operations - TFunction_DriverTable::Get()->AddDriver(GEOMImpl_PipeTShapeDriver::GetID(), new GEOMImpl_PipeTShapeDriver()); - TFunction_DriverTable::Get()->AddDriver(GEOMImpl_DividedDiskDriver::GetID(), new GEOMImpl_DividedDiskDriver()); -// TFunction_DriverTable::Get()->AddDriver(GEOMImpl_DividedCylinderDriver::GetID(), new GEOMImpl_DividedCylinderDriver()); - TFunction_DriverTable::Get()->AddDriver(GEOMImpl_SmoothingSurfaceDriver::GetID(), new GEOMImpl_SmoothingSurfaceDriver()); - /*@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@*/ - SetEngine(this); } @@ -405,18 +392,3 @@ GEOMImpl_IGroupOperations* GEOMImpl_Gen::GetIGroupOperations(int theDocID) return _mapOfGroupOperations[theDocID]; } - -//============================================================================= -/*! - * GetIAdvancedOperations - */ -//============================================================================= -GEOMImpl_IAdvancedOperations* GEOMImpl_Gen::GetIAdvancedOperations(int theDocID) -{ - if(_mapOfAdvancedOperations.find(theDocID) == _mapOfAdvancedOperations.end()) { - _mapOfAdvancedOperations[theDocID] = new GEOMImpl_IAdvancedOperations(this, theDocID); - } - - return _mapOfAdvancedOperations[theDocID]; -} - diff --git a/src/GEOMImpl/GEOMImpl_Gen.hxx b/src/GEOMImpl/GEOMImpl_Gen.hxx index ed9e7752d..06ca4ff63 100644 --- a/src/GEOMImpl/GEOMImpl_Gen.hxx +++ b/src/GEOMImpl/GEOMImpl_Gen.hxx @@ -39,7 +39,6 @@ #include "GEOMImpl_IInsertOperations.hxx" #include "GEOMImpl_IMeasureOperations.hxx" #include "GEOMImpl_IGroupOperations.hxx" -#include "GEOMImpl_IAdvancedOperations.hxx" #include "GEOM_Engine.hxx" class GEOMIMPL_EXPORT GEOMImpl_Gen : public GEOM_Engine @@ -72,8 +71,6 @@ class GEOMIMPL_EXPORT GEOMImpl_Gen : public GEOM_Engine GEOMImpl_IGroupOperations* GetIGroupOperations(int theDocID); - GEOMImpl_IAdvancedOperations* GetIAdvancedOperations(int theDocID); - private: std::map _mapOfBasicOperations; @@ -88,7 +85,6 @@ class GEOMIMPL_EXPORT GEOMImpl_Gen : public GEOM_Engine std::map _mapOfInsertOperations; std::map _mapOfMeasureOperations; std::map _mapOfGroupOperations; - std::map _mapOfAdvancedOperations; }; #endif diff --git a/src/GEOMImpl/GEOMImpl_IAdvancedOperations.cxx b/src/GEOMImpl/GEOMImpl_IAdvancedOperations.cxx deleted file mode 100644 index 42d457fc4..000000000 --- a/src/GEOMImpl/GEOMImpl_IAdvancedOperations.cxx +++ /dev/null @@ -1,3472 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// File : GEOMImpl_IAdvancedOperations.cxx -// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) - -#include "GEOMImpl_IAdvancedOperations.hxx" - -#include - -#include -#include -#include - -#include "GEOM_Function.hxx" -#include "GEOM_PythonDump.hxx" -#include "GEOMUtils.hxx" -#include "GEOMAlgo_Splitter.hxx" -#include "GEOMAlgo_FinderShapeOn1.hxx" - -#include "GEOMImpl_Gen.hxx" -#include "GEOMImpl_Types.hxx" - -#include "GEOMImpl_IBasicOperations.hxx" -#include "GEOMImpl_IBooleanOperations.hxx" -#include "GEOMImpl_IShapesOperations.hxx" -#include "GEOMImpl_ITransformOperations.hxx" -#include "GEOMImpl_IBlocksOperations.hxx" -#include "GEOMImpl_I3DPrimOperations.hxx" -#include "GEOMImpl_ILocalOperations.hxx" -#include "GEOMImpl_IHealingOperations.hxx" -#include "GEOMImpl_IGroupOperations.hxx" - -#include "GEOMImpl_GlueDriver.hxx" -#include "GEOMImpl_PipeTShapeDriver.hxx" -#include "GEOMImpl_IPipeTShape.hxx" -#include "GEOMImpl_DividedDiskDriver.hxx" -#include "GEOMImpl_IDividedDisk.hxx" -// #include "GEOMImpl_DividedCylinderDriver.hxx" -// #include "GEOMImpl_IDividedCylinder.hxx" -#include -#include -/*@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@*/ - -#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 // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC - -#define HALF_LENGTH_MAIN_PIPE "Main pipe half length" //"Tuyau principal - demi longueur" -#define HALF_LENGTH_INCIDENT_PIPE "Incident pipe half length" //"Tuyau incident - demi longueur" -#define CIRCULAR_QUARTER_PIPE "Circular quarter of pipe" //"Circulaire - quart de tuyau" -#define THICKNESS "Thickness" //"Epaisseur" -#define FLANGE "Flange" // "Collerette" -#define CHAMFER_OR_FILLET "Chamfer or fillet" //"Chanfrein ou Raccord" -#define JUNCTION_FACE_1 "Junction 1" //"Face de jonction 1" -#define JUNCTION_FACE_2 "Junction 2" //"Face de jonction 2" -#define JUNCTION_FACE_3 "Junction 3" //"Face de jonction 3" - -#define FIND_GROUPS_BY_POINTS 1 - -//============================================================================= -/*! - * Constructor - */ -//============================================================================= -GEOMImpl_IAdvancedOperations::GEOMImpl_IAdvancedOperations(GEOM_Engine* theEngine, int theDocID) : - GEOM_IOperations(theEngine, theDocID) -{ - MESSAGE("GEOMImpl_IAdvancedOperations::GEOMImpl_IAdvancedOperations"); - myBasicOperations = new GEOMImpl_IBasicOperations(GetEngine(), GetDocID()); - myBooleanOperations = new GEOMImpl_IBooleanOperations(GetEngine(), GetDocID()); - myShapesOperations = new GEOMImpl_IShapesOperations(GetEngine(), GetDocID()); - myTransformOperations = new GEOMImpl_ITransformOperations(GetEngine(), GetDocID()); - myBlocksOperations = new GEOMImpl_IBlocksOperations(GetEngine(), GetDocID()); - my3DPrimOperations = new GEOMImpl_I3DPrimOperations(GetEngine(), GetDocID()); - myLocalOperations = new GEOMImpl_ILocalOperations(GetEngine(), GetDocID()); - myHealingOperations = new GEOMImpl_IHealingOperations(GetEngine(), GetDocID()); - myGroupOperations = new GEOMImpl_IGroupOperations(GetEngine(), GetDocID()); -} - -//============================================================================= -/*! - * Destructor - */ -//============================================================================= -GEOMImpl_IAdvancedOperations::~GEOMImpl_IAdvancedOperations() -{ - MESSAGE("GEOMImpl_IAdvancedOperations::~GEOMImpl_IAdvancedOperations"); - delete myBasicOperations; - delete myBooleanOperations; - delete myShapesOperations; - delete myTransformOperations; - delete myBlocksOperations; - delete my3DPrimOperations; - delete myLocalOperations; - delete myHealingOperations; - delete myGroupOperations; -} - -//============================================================================= -/*! - * SetPosition - */ -//============================================================================= -gp_Trsf GEOMImpl_IAdvancedOperations::GetPositionTrsf(double theL1, double theL2, - Handle(GEOM_Object) theP1, - Handle(GEOM_Object) theP2, - Handle(GEOM_Object) theP3) -{ - // Old Local Coordinates System oldLCS - gp_Pnt P0(0, 0, 0); - gp_Pnt P1(-theL1, 0, 0); - gp_Pnt P2(theL1, 0, 0); - gp_Pnt P3(0, 0, theL2); - - gp_Dir oldX(gp_Vec(P1, P2)); - gp_Dir oldZ(gp_Vec(P0, P3)); - gp_Ax3 oldLCS(P0, oldZ, oldX); - - // New Local Coordinates System newLCS - double LocX, LocY, LocZ; - gp_Pnt newP1 = BRep_Tool::Pnt(TopoDS::Vertex(theP1->GetValue())); - gp_Pnt newP2 = BRep_Tool::Pnt(TopoDS::Vertex(theP2->GetValue())); - gp_Pnt newP3 = BRep_Tool::Pnt(TopoDS::Vertex(theP3->GetValue())); - LocX = (newP1.X() + newP2.X()) / 2.; - LocY = (newP1.Y() + newP2.Y()) / 2.; - LocZ = (newP1.Z() + newP2.Z()) / 2.; - gp_Pnt newO(LocX, LocY, LocZ); - - gp_Dir newX(gp_Vec(newP1, newP2)); // P1P2 Vector - gp_Dir newZ(gp_Vec(newO, newP3)); // OP3 Vector - gp_Ax3 newLCS = gp_Ax3(newO, newZ, newX); - - gp_Trsf aTrsf; - aTrsf.SetDisplacement(oldLCS, newLCS); - - return aTrsf; -} - -//============================================================================= -/*! - * CheckCompatiblePosition - * - */ -//============================================================================= -bool GEOMImpl_IAdvancedOperations::CheckCompatiblePosition(double& theL1, double& theL2, - Handle(GEOM_Object) theP1, - Handle(GEOM_Object) theP2, - Handle(GEOM_Object) theP3, - double theTolerance) -{ - SetErrorCode(KO); - gp_Pnt P1 = BRep_Tool::Pnt(TopoDS::Vertex(theP1->GetValue())); - gp_Pnt P2 = BRep_Tool::Pnt(TopoDS::Vertex(theP2->GetValue())); - gp_Pnt P3 = BRep_Tool::Pnt(TopoDS::Vertex(theP3->GetValue())); - - double d12 = P1.Distance(P2); - double d13 = P1.Distance(P3); - double d23 = P2.Distance(P3); - // double d2 = newO.Distance(P3); - - if (Abs(d12) <= Precision::Confusion()) { - SetErrorCode("Junctions points P1 and P2 are identical"); - return false; - } - if (Abs(d13) <= Precision::Confusion()) { - SetErrorCode("Junctions points P1 and P3 are identical"); - return false; - } - if (Abs(d23) <= Precision::Confusion()) { - SetErrorCode("Junctions points P2 and P3 are identical"); - return false; - } - - - double newL1 = 0.5 * d12; - double newL2 = sqrt(pow(d13,2)-pow(newL1,2)); - // - // theL1*(1-theTolerance) <= newL1 <= theL1*(1+theTolerance) - // - if (fabs(newL1 - theL1) > Precision::Approximation()) { - if ( (newL1 * (1 - theTolerance) -theL1 <= Precision::Approximation()) && - (newL1 * (1 + theTolerance) -theL1 >= Precision::Approximation()) ) { - // std::cerr << "theL1 = newL1" << std::endl; - theL1 = newL1; - } else { - theL1 = -1; - SetErrorCode("Dimension for main pipe (L1) is incompatible with new position"); - return false; - } - } - - // - // theL2*(1-theTolerance) <= newL2 <= theL2*(1+theTolerance) - // - if (fabs(newL2 - theL2) > Precision::Approximation()) { - if ( (newL2 * (1 - theTolerance) -theL2 <= Precision::Approximation()) && - (newL2 * (1 + theTolerance) -theL2 >= Precision::Approximation()) ) { - theL2 = newL2; - } else { - theL2 = -1; - SetErrorCode("Dimension for incident pipe (L2) is incompatible with new position"); - return false; - } - } - - SetErrorCode(OK); - return true; - -} - -//============================================================================= -/*! - * Generate the propagation groups of a Pipe T-Shape used for hexa mesh - */ -//============================================================================= -bool GEOMImpl_IAdvancedOperations::MakeGroups(Handle(GEOM_Object) theShape, int shapeType, - double theR1, double theW1, double theL1, - double theR2, double theW2, double theL2, - double theH, double theW, double theRF, - Handle(TColStd_HSequenceOfTransient) theSeq, - gp_Trsf aTrsf) -{ - SetErrorCode(KO); - - if (theShape.IsNull()) return false; - - TopoDS_Shape aShape = theShape->GetValue(); - if (aShape.IsNull()) { - SetErrorCode("Shape is not defined"); - return false; - } - - gp_Trsf aTrsfInv = aTrsf.Inverted(); - -// int expectedGroups = 0; -// if (shapeType == TSHAPE_BASIC) -// if (Abs(theR2+theW2-theR1-theW1) <= Precision::Approximation()) -// expectedGroups = 10; -// else -// expectedGroups = 11; -// else if (shapeType == TSHAPE_CHAMFER || shapeType == TSHAPE_FILLET) -// expectedGroups = 12; - - double aR1Ext = theR1 + theW1; - double aR2Ext = theR2 + theW2; - - ///////////////////////// - //// Groups of Faces //// - ///////////////////////// - - // - // Comment the following lines when GetInPlace bug is solved - // == BEGIN - // Workaround of GetInPlace bug - // Create a bounding box that fits the shape - Handle(GEOM_Object) aBox = my3DPrimOperations->MakeBoxDXDYDZ(2*theL1, 2*aR1Ext, aR1Ext+theL2); - aBox->GetLastFunction()->SetDescription(""); - myTransformOperations->TranslateDXDYDZ(aBox, -theL1, -aR1Ext, -aR1Ext); - aBox->GetLastFunction()->SetDescription(""); - // Apply transformation to box - BRepBuilderAPI_Transform aTransformationBox(aBox->GetValue(), aTrsf, Standard_False); - TopoDS_Shape aBoxShapeTrsf = aTransformationBox.Shape(); - aBox->GetLastFunction()->SetValue(aBoxShapeTrsf); - - // Get the shell of the box - Handle(GEOM_Object) aShell = Handle(GEOM_Object)::DownCast - (myShapesOperations->MakeExplode(aBox, TopAbs_SHELL, true)->Value(1)); - aBox->GetLastFunction()->SetDescription(""); - aShell->GetLastFunction()->SetDescription(""); - // Get the common shapes between shell and shape - Handle(GEOM_Object) aCommonCompound = myBooleanOperations->MakeBoolean (theShape, aShell, 1); // MakeCommon - if (aCommonCompound.IsNull()) { - SetErrorCode(myBooleanOperations->GetErrorCode()); - return false; - } - aCommonCompound->GetLastFunction()->SetDescription(""); - // Explode the faces of common shapes => 3 faces - Handle(TColStd_HSequenceOfTransient) aCommonFaces = - myShapesOperations->MakeExplode(aCommonCompound, TopAbs_FACE, true); - aCommonCompound->GetLastFunction()->SetDescription(""); - std::list aCompoundOfFacesList; - - for (int i=0 ; i<= aCommonFaces->Length()-4 ; i+=4) { - std::list aFacesList; - for (int j = 1 ; j <= 4 ; j++) { - Handle(GEOM_Object) aFace = Handle(GEOM_Object)::DownCast(aCommonFaces->Value(i+j)); // Junction faces - if (!aFace.IsNull()) { - aFace->GetLastFunction()->SetDescription(""); - aFacesList.push_back(aFace); - } - } - Handle(GEOM_Object) aCompoundOfFaces = myShapesOperations->MakeCompound(aFacesList); - if (!aCompoundOfFaces.IsNull()) { - aCompoundOfFaces->GetLastFunction()->SetDescription(""); - aCompoundOfFacesList.push_back(aCompoundOfFaces); - } - } - - if (aCompoundOfFacesList.size() == 3) { - Handle(GEOM_Object) aPln1 = aCompoundOfFacesList.front(); - aCompoundOfFacesList.pop_front(); - Handle(GEOM_Object) aPln2 = aCompoundOfFacesList.front(); - aCompoundOfFacesList.pop_front(); - Handle(GEOM_Object) aPln3 = aCompoundOfFacesList.front(); - aCompoundOfFacesList.pop_front(); - // == END - // - - - // Uncomment the following lines when GetInPlace bug is solved - // == BEGIN -// Handle(GEOM_Object) aP1 = myBasicOperations->MakePointXYZ(-theL1, 0, 0); -// Handle(GEOM_Object) aP2 = myBasicOperations->MakePointXYZ(-0, 0, theL2); -// Handle(GEOM_Object) aP3 = myBasicOperations->MakePointXYZ(theL1, 0, 0); -// aP1->GetLastFunction()->SetDescription(""); -// aP2->GetLastFunction()->SetDescription(""); -// aP3->GetLastFunction()->SetDescription(""); -// Handle(GEOM_Object) aV1 = myBasicOperations->MakeVectorDXDYDZ(-1, 0, 0); -// Handle(GEOM_Object) aV2 = myBasicOperations->MakeVectorDXDYDZ(0, 0, 1); -// Handle(GEOM_Object) aV3 = myBasicOperations->MakeVectorDXDYDZ(1, 0, 0); -// aV1->GetLastFunction()->SetDescription(""); -// aV2->GetLastFunction()->SetDescription(""); -// aV3->GetLastFunction()->SetDescription(""); -// Handle(GEOM_Object) aPln1 = myBasicOperations->MakePlanePntVec(aP1, aV1, 2*(aR1Ext+theL2)); -// Handle(GEOM_Object) aPln2 = myBasicOperations->MakePlanePntVec(aP2, aV2, 2*(aR2Ext)); -// Handle(GEOM_Object) aPln3 = myBasicOperations->MakePlanePntVec(aP3, aV3, 2*(aR1Ext+theL2)); -// aPln1->GetLastFunction()->SetDescription(""); -// aPln2->GetLastFunction()->SetDescription(""); -// aPln3->GetLastFunction()->SetDescription(""); -// -// BRepBuilderAPI_Transform aTransformation1(aPln1->GetValue(), aTrsf, Standard_False); -// TopoDS_Shape aTrsf_Shape1 = aTransformation1.Shape(); -// aPln1->GetLastFunction()->SetValue(aTrsf_Shape1); -// BRepBuilderAPI_Transform aTransformation2(aPln2->GetValue(), aTrsf, Standard_False); -// TopoDS_Shape aTrsf_Shape2 = aTransformation2.Shape(); -// aPln2->GetLastFunction()->SetValue(aTrsf_Shape2); -// BRepBuilderAPI_Transform aTransformation3(aPln3->GetValue(), aTrsf, Standard_False); -// TopoDS_Shape aTrsf_Shape3 = aTransformation3.Shape(); -// aPln3->GetLastFunction()->SetValue(aTrsf_Shape3); - // == END - // - - Handle(GEOM_Object) junctionFaces1 = myShapesOperations->GetInPlace(theShape, aPln1); - if (junctionFaces1.IsNull()) - junctionFaces1 = myShapesOperations->GetShapesOnShapeAsCompound - (aPln1, theShape, TopAbs_FACE, GEOMAlgo_ST_ONIN); - if (!junctionFaces1.IsNull()) { - junctionFaces1->GetLastFunction()->SetDescription(""); - junctionFaces1->SetName("JUNCTION_FACE_1"); - theSeq->Append(junctionFaces1); - } - else { - SetErrorCode("Junction face 1 not found"); - // theSeq->Append(aPln1); - // return false; - } - Handle(GEOM_Object) junctionFaces2 = myShapesOperations->GetInPlace(theShape, aPln2); - if (junctionFaces2.IsNull()) - junctionFaces2 = myShapesOperations->GetShapesOnShapeAsCompound - (aPln2, theShape, TopAbs_FACE, GEOMAlgo_ST_ONIN); - if (!junctionFaces2.IsNull()) { - junctionFaces2->GetLastFunction()->SetDescription(""); - junctionFaces2->SetName("JUNCTION_FACE_2"); - theSeq->Append(junctionFaces2); - } - else { - SetErrorCode("Junction face 2 not found"); - // theSeq->Append(aPln2); - // return false; - } - Handle(GEOM_Object) junctionFaces3 = myShapesOperations->GetInPlace(theShape, aPln3); - if (junctionFaces3.IsNull()) - junctionFaces3 = myShapesOperations->GetShapesOnShapeAsCompound - (aPln3, theShape, TopAbs_FACE, GEOMAlgo_ST_ONIN); - if (!junctionFaces3.IsNull()) { - junctionFaces3->GetLastFunction()->SetDescription(""); - junctionFaces3->SetName("JUNCTION_FACE_3"); - theSeq->Append(junctionFaces3); - } - else { - SetErrorCode("Junction face 3 not found"); - // theSeq->Append(aPln3); - // return false; - } - // Comment the following lines when GetInPlace bug is solved - // == BEGIN - } - // == END - - ///////////////////////// - //// Groups of Edges //// - ///////////////////////// - // Result of propagate - - Handle(GEOM_Function) aFunction = theShape->GetLastFunction(); - - TCollection_AsciiString theDesc = aFunction->GetDescription(); - Handle(TColStd_HSequenceOfTransient) aSeqPropagate = myBlocksOperations->Propagate(theShape); - if (aSeqPropagate.IsNull() || aSeqPropagate->Length() == 0) { - SetErrorCode("Propagation groups not found"); - return false; - } - Standard_Integer aNbGroups = aSeqPropagate->Length(); - // Recover previous description to get rid of Propagate dump - aFunction->SetDescription(theDesc); - -#ifdef FIND_GROUPS_BY_POINTS - // BEGIN: new groups search - - // W2 R2 - // .----.-----.----. - // e| | | | | - // | | | | | - // . | | | . - // g / ''..| | |..'' \ - // f / ''''''' \ - // .---.--'.. | | | ..'--.---. - // |a \ '''...........''' / | - // |-------\------' | '------/-------. - // | \ | / | - // c| \ | / | - // | R1 \ | / | - // | \ | / | - // ._________________|_________________. - // | L1 | | - // | | | - // | | | - // b| | | - // | | | - // |-----------------|-----------------| - // | W1 | | - // '-----------------'-----------------' - // d - - // "Thickness" group (a) - gp_Pnt aPntA (-theL1, 0, theR1 + theW1/2.); - aPntA.Transform(aTrsf); - BRepBuilderAPI_MakeVertex mkVertexA (aPntA); - TopoDS_Vertex aVertA = TopoDS::Vertex(mkVertexA.Shape()); - TopoDS_Shape anEdgeA = GEOMUtils::GetEdgeNearPoint(aShape, aVertA); - - // "Circular quarter of pipe" group (b) - gp_Pnt aPntB (-theL1, -aR1Ext * sin(M_PI/4.), -aR1Ext * sin(M_PI/4.)); - aPntB.Transform(aTrsf); - BRepBuilderAPI_MakeVertex mkVertexB (aPntB); - TopoDS_Vertex aVertB = TopoDS::Vertex(mkVertexB.Shape()); - TopoDS_Shape anEdgeB = GEOMUtils::GetEdgeNearPoint(aShape, aVertB); - - // "Circular quarter of pipe" group (c) - gp_Pnt aPntC (-theL1, -aR1Ext * sin(M_PI/4.), aR1Ext * sin(M_PI/4.)); - aPntC.Transform(aTrsf); - BRepBuilderAPI_MakeVertex mkVertexC (aPntC); - TopoDS_Vertex aVertC = TopoDS::Vertex(mkVertexC.Shape()); - TopoDS_Shape anEdgeC = GEOMUtils::GetEdgeNearPoint(aShape, aVertC); - - // "Main pipe half length" group (d) - gp_Pnt aPntD (-theL1/2., 0, -aR1Ext); - aPntD.Transform(aTrsf); - BRepBuilderAPI_MakeVertex mkVertexD (aPntD); - TopoDS_Vertex aVertD = TopoDS::Vertex(mkVertexD.Shape()); - TopoDS_Shape anEdgeD = GEOMUtils::GetEdgeNearPoint(aShape, aVertD); - - // "Incident pipe half length" group (e) - double aTol10 = Precision::Confusion() * 10.; - gp_Pnt aPntE (-aR2Ext, 0, theL2 - aTol10); - aPntE.Transform(aTrsf); - BRepBuilderAPI_MakeVertex mkVertexE (aPntE); - TopoDS_Vertex aVertE = TopoDS::Vertex(mkVertexE.Shape()); - TopoDS_Shape anEdgeE = GEOMUtils::GetEdgeNearPoint(aShape, aVertE); - - // "Flange" group (f) - double aFx = - aR2Ext - aTol10; - if (shapeType == TSHAPE_CHAMFER) - aFx -= theW; - else if (shapeType == TSHAPE_FILLET) - aFx -= theRF; - gp_Pnt aPntF (aFx, 0, aR1Ext); - aPntF.Transform(aTrsf); - BRepBuilderAPI_MakeVertex mkVertexF (aPntF); - TopoDS_Vertex aVertF = TopoDS::Vertex(mkVertexF.Shape()); - TopoDS_Shape anEdgeF = GEOMUtils::GetEdgeNearPoint(aShape, aVertF); - - // "Chamfer or Fillet" group (g) - TopoDS_Shape anEdgeG; - if (shapeType == TSHAPE_CHAMFER) { - gp_Pnt aPntG (-aR2Ext - theW/2., 0, aR1Ext + theH/2.); - aPntG.Transform(aTrsf); - BRepBuilderAPI_MakeVertex mkVertexG (aPntG); - TopoDS_Vertex aVertG = TopoDS::Vertex(mkVertexG.Shape()); - anEdgeG = GEOMUtils::GetEdgeNearPoint(aShape, aVertG); - } - else if (shapeType == TSHAPE_FILLET) { - gp_Pnt aPntG (-aR2Ext - theRF/2., 0, aR1Ext + theRF/2.); - aPntG.Transform(aTrsf); - BRepBuilderAPI_MakeVertex mkVertexG (aPntG); - TopoDS_Vertex aVertG = TopoDS::Vertex(mkVertexG.Shape()); - anEdgeG = GEOMUtils::GetEdgeNearPoint(aShape, aVertG); - } - - for (int i = 1 ; i <= aNbGroups; i++) { - Handle(GEOM_Object) aGroup = Handle(GEOM_Object)::DownCast(aSeqPropagate->Value(i)); - if (aGroup.IsNull()) - continue; - - TopoDS_Shape aGroupShape = aGroup->GetValue(); - TopTools_IndexedMapOfShape anEdgesMap; - TopExp::MapShapes(aGroupShape, TopAbs_EDGE, anEdgesMap); - - if (anEdgesMap.Contains(anEdgeA)) { // a - aGroup->SetName("THICKNESS"); - theSeq->Append(aGroup); - } - else if (anEdgesMap.Contains(anEdgeB)) { // b - aGroup->SetName("CIRCULAR_QUARTER_PIPE"); - theSeq->Append(aGroup); - } - else if (anEdgesMap.Contains(anEdgeC)) { // c - aGroup->SetName("CIRCULAR_QUARTER_PIPE"); - theSeq->Append(aGroup); - } - else if (anEdgesMap.Contains(anEdgeD)) { // d - aGroup->SetName("HALF_LENGTH_MAIN_PIPE"); - theSeq->Append(aGroup); - } - else if (anEdgesMap.Contains(anEdgeE)) { // e - aGroup->SetName("HALF_LENGTH_INCIDENT_PIPE"); - theSeq->Append(aGroup); - } - else if (anEdgesMap.Contains(anEdgeF)) { // f - aGroup->SetName("FLANGE"); - theSeq->Append(aGroup); - } - else if (shapeType == TSHAPE_CHAMFER) { // g - if (anEdgesMap.Contains(anEdgeG)) { - aGroup->SetName("CHAMFER"); - theSeq->Append(aGroup); - } - } - else if (shapeType == TSHAPE_FILLET) { // g - if (anEdgesMap.Contains(anEdgeG)) { - aGroup->SetName("FILLET"); - theSeq->Append(aGroup); - } - } - else { - } - } - // END: new groups search -#else - bool addGroup; - bool circularFoundAndAdded = false; - bool circularFound10 = false; - bool incidentPipeFound = false; - bool mainPipeFound = false; - bool mainPipeFoundAndAdded = false; - bool radialFound =false; - bool flangeFound = false; - bool flangeFoundAndAdded = false; - bool chamferOrFilletFound = false; - - for (int i = 1 ; i <= aNbGroups; i++) { - addGroup = false; - - Handle(GEOM_Object) aGroup = Handle(GEOM_Object)::DownCast(aSeqPropagate->Value(i)); - if (aGroup.IsNull()) - continue; - - TopoDS_Shape aGroupShape = aGroup->GetValue(); - BRepBuilderAPI_Transform aTransformationShapeInv (aGroupShape, aTrsfInv, Standard_False); - TopoDS_Shape aGroupShapeTrsfInv = aTransformationShapeInv.Shape(); - - TopTools_IndexedMapOfShape anEdgesMap; - TopExp::MapShapes(aGroupShapeTrsfInv,TopAbs_EDGE, anEdgesMap); - Standard_Integer nbEdges = anEdgesMap.Extent(); - - if (shapeType == TSHAPE_BASIC) { - if ((nbEdges >= 21) || /*R1Ext = R2Ext*/(nbEdges == 17)) { // 17, 17+8*{1,2,3}, 21, 21+8*{1,2,3} - addGroup = true; - aGroup->SetName("THICKNESS"); - } - else if (nbEdges == 6) { - if (!circularFoundAndAdded) { - circularFoundAndAdded = true; - addGroup = true; - aGroup->SetName("CIRCULAR_QUARTER_PIPE"); - } - } - else if (nbEdges == 8) { - incidentPipeFound = true; - mainPipeFound = false; - radialFound = false; - flangeFound = false; - - TopExp_Explorer Ex(aGroupShapeTrsfInv,TopAbs_VERTEX); - while (Ex.More()) { - gp_Pnt aP = BRep_Tool::Pnt(TopoDS::Vertex(Ex.Current())); - double x=aP.X(), y=aP.Y(), z=aP.Z(); - - - if ((Abs(x) > aR2Ext + Precision::Confusion()) || - (Abs(y) > aR2Ext + Precision::Confusion())) { - incidentPipeFound = false; - } - - if ( z < -Precision::Confusion()) { - // length of main pipe - mainPipeFound = true; - if (!mainPipeFoundAndAdded) { - mainPipeFoundAndAdded = true; - addGroup = true; - aGroup->SetName("HALF_LENGTH_MAIN_PIPE"); - } - } - - else if (Abs(x) > (theL1-Precision::Confusion())) { - // discretisation circulaire - radialFound = true; - if (!circularFoundAndAdded) { - circularFoundAndAdded = true; - addGroup = true; - aGroup->SetName("CIRCULAR_QUARTER_PIPE"); - } - } - Ex.Next(); - } - if (incidentPipeFound) { - addGroup = true; - aGroup->SetName("HALF_LENGTH_INCIDENT_PIPE"); - } - if (!addGroup && (!incidentPipeFound && - !radialFound && - !mainPipeFound && - !flangeFound)) { - // Flange (collerette) - flangeFound = true; - addGroup = true; - aGroup->SetName("FLANGE"); - } - } - else - continue; - } - else if (shapeType == TSHAPE_CHAMFER || shapeType == TSHAPE_FILLET) { - if (nbEdges >= 25) { // 25, 25+8, 25+16, 25+24 - addGroup = true; - aGroup->SetName("THICKNESS"); - } - else if ((nbEdges == 10) || (nbEdges == 6)) { - if (!circularFoundAndAdded) { - addGroup = true; - circularFoundAndAdded = true; - aGroup->SetName("CIRCULAR_QUARTER_PIPE"); - if (nbEdges == 10) { - circularFound10 = true; - } - } - else if (!circularFound10 && nbEdges == 10) { - circularFound10 = true; - addGroup = true; - aGroup->SetName("CIRCULAR_QUARTER_PIPE"); - } - } - else if (nbEdges == 8) { - incidentPipeFound = true; - mainPipeFound = true; - flangeFound = false; - - bool isNearZ0 = false; - bool isBelowZ0 = false; - - TopExp_Explorer Ex (aGroupShapeTrsfInv,TopAbs_VERTEX); - while (Ex.More()) { - gp_Pnt aP = BRep_Tool::Pnt(TopoDS::Vertex(Ex.Current())); - double x=aP.X(), y=aP.Y(), z=aP.Z(); - - // tuy_princ_long_avant & tuy_princ_long_apres - //bool isMain = (((z < Precision::Confusion()) || (x < Precision::Confusion())) && - // ((y <= aR1Ext + Precision::Confusion()) || - // (y <= -(aR1Ext + Precision::Confusion())) || - // (y <= theR1 + Precision::Confusion()) || - // (y == -(theR1 + Precision::Confusion())))); - bool isMain = ((z < Precision::Confusion() || x < Precision::Confusion()) && - (fabs(y) > theR1 - Precision::Confusion() || - fabs(y) < Precision::Confusion())); - - if (!isMain) { - mainPipeFound = false; - } - - // collerette - //if (z < Precision::Confusion() && !isMain) { - // flangeFound = true; - // if (!flangeFoundAndAdded) { - // flangeFoundAndAdded = true; - // addGroup = true; - // aGroup->SetName("FLANGE"); - // } - //} - if (fabs(z) < Precision::Confusion()) isNearZ0 = true; - if (z < - Precision::Confusion()) isBelowZ0 = true; - - // tuyau incident - if ((Abs(x) > aR2Ext + Precision::Confusion()) || - (Abs(y) > aR2Ext + Precision::Confusion())) { - incidentPipeFound = false; - } - Ex.Next(); - } - if (mainPipeFound) { - addGroup = true; - aGroup->SetName("HALF_LENGTH_MAIN_PIPE"); - } - if (incidentPipeFound) { - addGroup = true; - aGroup->SetName("HALF_LENGTH_INCIDENT_PIPE"); - } - if (isNearZ0 && !isBelowZ0) { - flangeFound = true; - if (!flangeFoundAndAdded) { - flangeFoundAndAdded = true; - addGroup = true; - aGroup->SetName("FLANGE"); - } - } - if (!addGroup && (!incidentPipeFound && - !mainPipeFound && - !flangeFound && - !chamferOrFilletFound)) { - addGroup = true; - chamferOrFilletFound = true; - if (shapeType == TSHAPE_CHAMFER) - aGroup->SetName("CHAMFER"); - else - aGroup->SetName("FILLET"); - } - } - else - continue; - } - // Add group to the list - if (addGroup) - theSeq->Append(aGroup); - } -#endif - - SetErrorCode(OK); - return true; -} - -//============================================================================= -/*! - * Return faces that are laying on surface. - */ -//============================================================================= -bool GEOMImpl_IAdvancedOperations::GetFacesOnSurf - (const TopoDS_Shape &theShape, - const Handle_Geom_Surface& theSurface, - const Standard_Real theTolerance, - TopTools_ListOfShape &theFaces) -{ - GEOMAlgo_FinderShapeOn1 aFinder; - - aFinder.SetShape(theShape); - aFinder.SetTolerance(theTolerance); - aFinder.SetSurface(theSurface); - aFinder.SetShapeType(TopAbs_FACE); - aFinder.SetState(GEOMAlgo_ST_ON); - - // Sets the minimal number of inner points for the faces that do not have own - // inner points at all (for e.g. rectangular planar faces have just 2 triangles). - // Default value=3 - aFinder.SetNbPntsMin(3); - // Sets the maximal number of inner points for edges or faces. - // It is usefull for the cases when this number is very big (e.g =2000) to improve - // the performance. If this value =0, all inner points will be taken into account. - // Default value=0 - aFinder.SetNbPntsMax(100); - aFinder.Perform(); - - // Interprete results - Standard_Integer iErr = aFinder.ErrorStatus(); - // the detailed description of error codes is in GEOMAlgo_FinderShapeOn1.cxx - if (iErr) { - MESSAGE(" iErr : " << iErr); - TCollection_AsciiString aMsg (" iErr : "); - aMsg += TCollection_AsciiString(iErr); - SetErrorCode(aMsg); - return false; - } - Standard_Integer iWrn = aFinder.WarningStatus(); - // the detailed description of warning codes is in GEOMAlgo_FinderShapeOn1.cxx - if (iWrn) { - MESSAGE(" *** iWrn : " << iWrn); - } - - const TopTools_ListOfShape &aListRes = aFinder.Shapes(); // the result - TopTools_ListIteratorOfListOfShape anIter (aListRes); - - for (; anIter.More(); anIter.Next()) { - theFaces.Append(anIter.Value()); - } - - return true; -} - -//============================================================================= -/*! - * Creates and returns conical face. - */ -//============================================================================= -TopoDS_Shape GEOMImpl_IAdvancedOperations::MakeConicalFace - (const gp_Ax2 &theAxis, - const double theRadius, - const double theRadiusThin, - const double theHeight, - const gp_Trsf &theTrsf) -{ - BRepPrimAPI_MakeCone aMkCone (theAxis, theRadius, theRadiusThin, theHeight); - TopoDS_Shape aResult; - - aMkCone.Build(); - if (aMkCone.IsDone()) { - TopExp_Explorer anExp(aMkCone.Shape(), TopAbs_FACE); - - for (; anExp.More(); anExp.Next()) { - TopoDS_Face aFace = TopoDS::Face(anExp.Current()); - - if (aFace.IsNull() == Standard_False) { - BRepAdaptor_Surface anAdaptor(aFace, Standard_False); - - if (anAdaptor.GetType() == GeomAbs_Cone) { - // This is a conical face. Transform and return it. - BRepBuilderAPI_Transform aTransf(aFace, theTrsf, Standard_False); - - aResult = aTransf.Shape(); - break; - } - } - } - } - - return aResult; -} - -//============================================================================= -/*! - * Generate the internal group of a Pipe T-Shape - */ -//============================================================================= -bool GEOMImpl_IAdvancedOperations::MakeInternalGroup - (const Handle(GEOM_Object) &theShape, - const double theR1, const double theLen1, - const double theR2, const double theLen2, - const double theRL, double theTransLenL, - const double theRR, double theTransLenR, - const double theRI, double theTransLenI, - const Handle(TColStd_HSequenceOfTransient) &theSeq, - const gp_Trsf &theTrsf) -{ - SetErrorCode(KO); - - if (theShape.IsNull()) { - return false; - } - - TopoDS_Shape aShape = theShape->GetValue(); - - if (aShape.IsNull()) { - SetErrorCode("Shape is not defined"); - return false; - } - - // Compute tolerance - Standard_Real aMaxTol = -RealLast(); - TopExp_Explorer anExp(aShape, TopAbs_VERTEX); - - for (; anExp.More(); anExp.Next()) { - TopoDS_Vertex aVertex = TopoDS::Vertex(anExp.Current()); - - if (aVertex.IsNull() == Standard_False) { - const Standard_Real aTol = BRep_Tool::Tolerance(aVertex); - - if (aTol > aMaxTol) { - aMaxTol = aTol; - } - } - } - - // Construct internal surfaces. - Standard_Integer i = 0; - const Standard_Integer aMaxNbSurf = 5; - Handle(Geom_Surface) aSurface[aMaxNbSurf]; - TopTools_ListOfShape aConicalFaces; - Standard_Real aTolConf = Precision::Confusion(); - - // 1. Construct the internal surface of main pipe. - gp_Ax2 anAxis1 (gp::Origin(), gp::DX(), gp::DZ()); - gp_Ax2 anAxis2 (gp::Origin(), gp::DZ(), gp::DX()); - - aSurface[i++] = new Geom_CylindricalSurface(anAxis1, theR1); - - // 2. Construct the internal surface of incident pipe. - aSurface[i++] = new Geom_CylindricalSurface(anAxis2, theR2); - - // 3. Construct the internal surface of left reduction pipe. - if (theRL > aTolConf) { - aSurface[i++] = new Geom_CylindricalSurface(anAxis1, theRL); - - if (theTransLenL > aTolConf) { - // 3.1. Construct the internal surface of left transition pipe. - gp_Pnt aPLeft (-theLen1, 0., 0.); - gp_Ax2 anAxisLeft (aPLeft, -gp::DX(), gp::DZ()); - TopoDS_Shape aConeLeft = - MakeConicalFace(anAxisLeft, theR1, theRL, theTransLenL, theTrsf); - - if (aConeLeft.IsNull() == Standard_False) { - aConicalFaces.Append(aConeLeft); - } - } - } - - // 4. Construct the internal surface of right reduction pipe. - if (theRR > aTolConf) { - // There is no need to construct another cylinder of the same radius. Skip it. - if (Abs(theRR - theRL) > aTolConf) { - aSurface[i++] = new Geom_CylindricalSurface(anAxis1, theRR); - } - - if (theTransLenL > aTolConf) { - // 4.1. Construct the internal surface of right transition pipe. - gp_Pnt aPRight (theLen1, 0., 0.); - gp_Ax2 anAxisRight (aPRight, gp::DX(), gp::DZ()); - TopoDS_Shape aConeRight = - MakeConicalFace(anAxisRight, theR1, theRR, theTransLenR, theTrsf); - - if (aConeRight.IsNull() == Standard_False) { - aConicalFaces.Append(aConeRight); - } - } - } - - // 5. Construct the internal surface of incident reduction pipe. - if (theRI > aTolConf) { - aSurface[i++] = new Geom_CylindricalSurface(anAxis2, theRI); - - if (theTransLenI > aTolConf) { - // 5.1. Construct the internal surface of incident transition pipe. - gp_Pnt aPInci (0., 0., theLen2); - gp_Ax2 anAxisInci (aPInci, gp::DZ(), gp::DX()); - TopoDS_Shape aConeInci = - MakeConicalFace(anAxisInci, theR2, theRI, theTransLenI, theTrsf); - - if (aConeInci.IsNull() == Standard_False) { - aConicalFaces.Append(aConeInci); - } - } - } - - // Get faces that are laying on cylindrical surfaces. - TopTools_ListOfShape aFaces; - gp_Trsf anInvTrsf = theTrsf.Inverted(); - - for (i = 0; i < aMaxNbSurf; i++) { - if (aSurface[i].IsNull()) { - break; - } - - aSurface[i]->Transform(theTrsf); - - TopTools_ListOfShape aLocalFaces; - - if (!GetFacesOnSurf(aShape, aSurface[i], aMaxTol, aLocalFaces)) { - return false; - } - - if (i < 2) { - // Check if the result contains outer cylinders. - // It is required for main and incident pipes. - TopTools_ListIteratorOfListOfShape anIter(aLocalFaces); - - while (anIter.More()) { - TopExp_Explorer anExp(anIter.Value(), TopAbs_VERTEX); - Standard_Boolean isInside = Standard_False; - - // Get a vertex from this shape - if (anExp.More()) { - TopoDS_Vertex aVtx = TopoDS::Vertex(anExp.Current()); - - if (aVtx.IsNull() == Standard_False) { - gp_Pnt aPnt = BRep_Tool::Pnt(aVtx); - - aPnt.Transform(anInvTrsf); - - if (i == 0) { - // Check if the point is inside the main pipe. - isInside = (Abs(aPnt.X()) <= theLen1); - } else { // i == 1 - // Check if the point is inside the incident pipe. - isInside = (aPnt.Z() <= theLen2); - } - } - } - - if (isInside) { - // Keep this face. - anIter.Next(); - } else { - // Remove this face. - aLocalFaces.Remove(anIter); - } - } - } - - aFaces.Append(aLocalFaces); - } - - // Get faces that are laying on conical faces. - if (aConicalFaces.IsEmpty() == Standard_False) { - Handle(GEOM_Object) aCone = - GetEngine()->AddObject(GetDocID(), GEOM_TSHAPE); - Handle(GEOM_Function) aFunction = - aCone->AddFunction(GEOMImpl_PipeTShapeDriver::GetID(), TSHAPE_BASIC); - TopTools_ListIteratorOfListOfShape aFIter(aConicalFaces); - Handle(GEOM_Object) aConeFromShape; - - for (; aFIter.More(); aFIter.Next()) { - aFunction->SetValue(aFIter.Value()); - aConeFromShape = myShapesOperations->GetInPlace(theShape, aCone); - - if (aConeFromShape.IsNull() == Standard_False) { - aConeFromShape->GetLastFunction()->SetDescription(""); - TopoDS_Shape aConeFaces = aConeFromShape->GetValue(); - TopExp_Explorer anExp(aConeFaces, TopAbs_FACE); - - for (; anExp.More(); anExp.Next()) { - TopoDS_Face aConeFace = TopoDS::Face(anExp.Current()); - - if (aConeFace.IsNull() == Standard_False) { - aFaces.Append(aConeFace); - } - } - } - } - } - - // Create a group of internal faces. - if (aFaces.IsEmpty() == Standard_False) { - Handle(GEOM_Object) aGroup = myGroupOperations->CreateGroup(theShape, TopAbs_FACE); - - if (aGroup.IsNull() == Standard_False) { - aGroup->GetLastFunction()->SetDescription(""); - aGroup->SetName("INTERNAL_FACES"); - - TopTools_IndexedMapOfShape anIndices; - Handle(TColStd_HSequenceOfInteger) aSeqIDs = new TColStd_HSequenceOfInteger; - - TopExp::MapShapes(aShape, anIndices); - - TopTools_ListIteratorOfListOfShape anIter(aFaces); - - for (; anIter.More(); anIter.Next()) { - const TopoDS_Shape &aFace = anIter.Value(); - const Standard_Integer anIndex = anIndices.FindIndex(aFace); - - if (anIndex > 0) { - aSeqIDs->Append(anIndex); - } - } - - myGroupOperations->UnionIDs(aGroup, aSeqIDs); - aGroup->GetLastFunction()->SetDescription(""); - theSeq->Append(aGroup); - } - } - - SetErrorCode(OK); - - return true; -} - -bool GEOMImpl_IAdvancedOperations::MakePipeTShapePartition(Handle(GEOM_Object) theShape, - double theR1, double theW1, double theL1, - double theR2, double theW2, double theL2, - double theH, double theW, - double theRF, bool isNormal) -{ - SetErrorCode(KO); - - // Build tools for partition operation: - // 1 face and 2 planes - // Face - Handle(GEOM_Object) arete_intersect_int; - Handle(GEOM_Object) wire_t, wire_t2, face_t, face_t2; - Handle(GEOM_Object) chan_racc; - Handle(GEOM_Object) vi1, vi2; - Handle(GEOM_Object) Te3; - - try { -#if OCC_VERSION_LARGE > 0x06010000 - OCC_CATCH_SIGNALS; -#endif - Handle(GEOM_Object) Vector_Z = myBasicOperations->MakeVectorDXDYDZ(0, 0, 1); - Vector_Z->GetLastFunction()->SetDescription(""); - - // Useful values - double aSize = 2*(theL1 + theL2); - double aR1Ext = theR1 + theW1; - double aR2Ext = theR2 + theW2; - double theVertCylinderRadius = aR2Ext + theW + theRF; - double theHoriCylinderRadius = aR1Ext + theH + theRF; - - // Common edges on internal cylinder - Handle(GEOM_Object) box_i = my3DPrimOperations->MakeBoxDXDYDZ(theR2, theR2, theR1); - box_i->GetLastFunction()->SetDescription(""); - box_i = myTransformOperations->TranslateDXDYDZ(box_i, -theR2, -theR2, 0); - box_i->GetLastFunction()->SetDescription(""); - - Handle(GEOM_Function) aFunction = theShape->GetLastFunction(); - TCollection_AsciiString theDesc = aFunction->GetDescription(); - Handle(TColStd_HSequenceOfTransient) edges_i = - myShapesOperations->GetShapesOnBox(box_i, theShape, TopAbs_EDGE, GEOMAlgo_ST_IN); - // Recover previous description to get rid of Propagate dump - aFunction->SetDescription(theDesc); - if (edges_i.IsNull() || edges_i->Length() == 0) { - SetErrorCode("Internal edges not found"); - return false; - } - for (int i=1; i<=edges_i->Length();i++) { - Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(edges_i->Value(i)); - anObj->GetLastFunction()->SetDescription(""); - } - arete_intersect_int = Handle(GEOM_Object)::DownCast(edges_i->Value(1)); - - // search for vertices located on both internal pipes - aFunction = theShape->GetLastFunction(); - theDesc = aFunction->GetDescription(); - Handle(TColStd_HSequenceOfTransient) vertices_i = - myShapesOperations->GetShapesOnBox(box_i, theShape, TopAbs_VERTEX, GEOMAlgo_ST_ONIN); - // Recover previous description to get rid of Propagate dump - aFunction->SetDescription(theDesc); - if (vertices_i.IsNull() || vertices_i->Length() == 0) { - SetErrorCode("Internal vertices not found"); - return false; - } - - for (int i = 1; i <= vertices_i->Length(); i++) { - Handle(GEOM_Object) v = Handle(GEOM_Object)::DownCast(vertices_i->Value(i)); - v->GetLastFunction()->SetDescription(""); - TopoDS_Vertex aVertex = TopoDS::Vertex(v->GetValue()); - gp_Pnt aP = BRep_Tool::Pnt(aVertex); -// std::cout << "Coords: " << aP.X() << ", " << aP.Y() << ", " << aP.Z() << std::endl; - if (Abs(aP.X()) <= Precision::Confusion()) { - if (Abs(aP.Y()) - theR1 <= Precision::Confusion()) { - vi1 = v; - } - } else if (Abs(aP.Y()) <= Precision::Confusion()) { - if (Abs(aP.X()) - theR1 <= Precision::Confusion()) { - vi2 = v; - } - } - } - - std::list theShapes; - - if (isNormal) { - Handle(GEOM_Object) ve1, ve2; - - Handle(GEOM_Object) box_e = my3DPrimOperations->MakeBoxDXDYDZ(aR2Ext, aR2Ext, aR1Ext); - box_e->GetLastFunction()->SetDescription(""); - box_e = myTransformOperations->TranslateDXDYDZ(box_e, -aR2Ext, -aR2Ext, 0); - box_e->GetLastFunction()->SetDescription(""); - // Common edges on external cylinder - aFunction = theShape->GetLastFunction(); - theDesc = aFunction->GetDescription(); - Handle(TColStd_HSequenceOfTransient) edges_e = - myShapesOperations->GetShapesOnBox(box_e, theShape, TopAbs_EDGE, GEOMAlgo_ST_IN); - // Recover previous description to get rid of Propagate dump - aFunction->SetDescription(theDesc); - if (edges_e.IsNull() || edges_e->Length() == 0) { - SetErrorCode("External edges not found"); - return false; - } - for (int i=1; i<=edges_e->Length();i++) { - Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(edges_e->Value(i)); - anObj->GetLastFunction()->SetDescription(""); - } - - // search for vertices located on both external pipes - aFunction = theShape->GetLastFunction(); - theDesc = aFunction->GetDescription(); - Handle(TColStd_HSequenceOfTransient) vertices_e = - myShapesOperations->GetShapesOnBox(box_e, theShape, TopAbs_VERTEX, GEOMAlgo_ST_ONIN); - // Recover previous description to get rid of Propagate dump - aFunction->SetDescription(theDesc); - if (vertices_e.IsNull() || vertices_e->Length() == 0) { - SetErrorCode("External vertices not found"); - return false; - } - - for (int i = 1; i <= vertices_e->Length(); i++) { - Handle(GEOM_Object) v = Handle(GEOM_Object)::DownCast(vertices_e->Value(i)); - v->GetLastFunction()->SetDescription(""); - TopoDS_Vertex aVertex = TopoDS::Vertex(v->GetValue()); - gp_Pnt aP = BRep_Tool::Pnt(aVertex); -// std::cout << "Coords: " << aP.X() << ", " << aP.Y() << ", " << aP.Z() << std::endl; - if (Abs(aP.X()) <= Precision::Confusion()) { - if (Abs(aP.Y()) - theR2 > Precision::Confusion()) { - ve1 = v; - } - } else if (Abs(aP.Y()) <= Precision::Confusion()) { - if (Abs(aP.X()) - theR2 > Precision::Confusion()) { - ve2 = v; - } - } - if ( !ve1.IsNull() && !ve2.IsNull()) - break; - } - Handle(GEOM_Object) edge_e1, edge_e2; - - edge_e1 = myBasicOperations->MakeLineTwoPnt(ve1, vi1); - if (edge_e1.IsNull()) { - SetErrorCode("Edge 1 could not be built"); - return false; - } - - edge_e2 = myBasicOperations->MakeLineTwoPnt(ve2, vi2); - if (edge_e2.IsNull()) { - SetErrorCode("Edge 2 could not be built"); - return false; - } - - edge_e1->GetLastFunction()->SetDescription(""); - edge_e2->GetLastFunction()->SetDescription(""); - - std::list edge_e_elist; - edge_e_elist.push_back(arete_intersect_int); - edge_e_elist.push_back(edge_e1); - edge_e_elist.push_back(Handle(GEOM_Object)::DownCast(edges_e->Value(1))); - edge_e_elist.push_back(edge_e2); - wire_t = myShapesOperations->MakeWire(edge_e_elist, 1e-7); - if (wire_t.IsNull()) { - SetErrorCode("Impossible to build wire"); - return false; - } - wire_t->GetLastFunction()->SetDescription(""); - face_t = myShapesOperations->MakeFace(wire_t, false); - if (face_t.IsNull()) { - SetErrorCode("Impossible to build face"); - return false; - } - face_t->GetLastFunction()->SetDescription(""); - - theShapes.push_back(theShape); - theShapes.push_back(vi1); - theShapes.push_back(vi2); - theShapes.push_back(ve1); - theShapes.push_back(ve2); - theShapes.push_back(edge_e1); - theShapes.push_back(edge_e2); - theShapes.push_back(wire_t); - theShapes.push_back(face_t); - } - else { - Handle(GEOM_Object) P1, P2, P3, P4, P5, P6; - int idP1, idP2, idP3, idP4; - int PZX, PZY; - double ZX=0, ZY=0; - std::vector LX; - std::vector LY; - Handle(GEOM_Object) box_e = my3DPrimOperations->MakeBoxDXDYDZ - (theVertCylinderRadius, theVertCylinderRadius, theHoriCylinderRadius); - box_e->GetLastFunction()->SetDescription(""); - box_e = myTransformOperations->TranslateDXDYDZ - (box_e, -theVertCylinderRadius, -theVertCylinderRadius, 0); - box_e->GetLastFunction()->SetDescription(""); - - aFunction = theShape->GetLastFunction(); - theDesc = aFunction->GetDescription(); - Handle(TColStd_HSequenceOfTransient) extremVertices = - myShapesOperations->GetShapesOnBox(box_e, theShape, TopAbs_VERTEX, GEOMAlgo_ST_ONIN); - // Recover previous description to get rid of Propagate dump - aFunction->SetDescription(theDesc); - - if (extremVertices.IsNull() || extremVertices->Length() == 0) { - if (theRF == 0) - SetErrorCode("Vertices on chamfer not found"); - else - SetErrorCode("Vertices on fillet not found"); - return false; - } - - theShapes.push_back(theShape); - theShapes.push_back(box_e); - if (extremVertices->Length() != 6) { - // for (int i=1; i<=extremVertices->Length(); i++){ - // theShapes.push_back(Handle(GEOM_Object)::DownCast(extremVertices->Value(i))); - // } - // Handle(GEOM_Object) aCompound = myShapesOperations->MakeCompound(theShapes); - // TopoDS_Shape aCompoundShape = aCompound->GetValue(); - // theShape->GetLastFunction()->SetValue(aCompoundShape); - SetErrorCode("Bad number of vertices on chamfer found"); - return false; - } - - for (int i=1; i<=extremVertices->Length(); i++){ - Handle(GEOM_Object) aV = Handle(GEOM_Object)::DownCast(extremVertices->Value(i)); - aV->GetLastFunction()->SetDescription(""); - gp_Pnt aP = BRep_Tool::Pnt(TopoDS::Vertex(aV->GetValue())); - - if (Abs(aP.X()) <= Precision::Confusion()) { - if (Abs(aP.Y()) - theR2 > Precision::Confusion()) { - LX.push_back(i); - if (aP.Z()-ZX > Precision::Confusion()) { - ZX = aP.Z(); - PZX = i; - } - } - } - else { - if (Abs(aP.X()) - theR2 > Precision::Confusion()) { - LY.push_back(i); - if (aP.Z() - ZY > Precision::Confusion()) { - ZY = aP.Z(); - PZY = i; - } - } - } - } - - idP2 = PZX; - idP4 = PZY; - idP1 = LX.at(0); - if (LX.at(0) == PZX) - idP1 = LX.at(1); - idP3 = LY.at(0); - if (LY.at(0) == PZY) - idP3 = LY.at(1); - - P1 = Handle(GEOM_Object)::DownCast(extremVertices->Value(idP1)); - P2 = Handle(GEOM_Object)::DownCast(extremVertices->Value(idP2)); - P3 = Handle(GEOM_Object)::DownCast(extremVertices->Value(idP3)); - P4 = Handle(GEOM_Object)::DownCast(extremVertices->Value(idP4)); - - Handle(GEOM_Object) Cote_1 = myBasicOperations->MakeLineTwoPnt(P1, vi1); - if (Cote_1.IsNull()) { - SetErrorCode("Impossible to build edge in thickness"); - return false; - } - Cote_1->GetLastFunction()->SetDescription(""); - - Handle(GEOM_Object) Cote_2 = myBasicOperations->MakeLineTwoPnt(vi2, P3); - if (Cote_2.IsNull()) { - SetErrorCode("Impossible to build edge in thickness"); - return false; - } - Cote_2->GetLastFunction()->SetDescription(""); - - // edge_chan_princ = arete du chanfrein (ou raccord) sur le tuyau principal - // edge_chan_inc = arete du chanfrein (ou raccord) sur le tuyau incident - // std::cerr << "Getting chamfer edge on main pipe" << std::endl; - Handle(GEOM_Object) edge_chan_princ = myBlocksOperations->GetEdge(theShape, P1, P3); - if (edge_chan_princ.IsNull()) { - SetErrorCode("Impossible to find edge on main pipe"); - return false; - } - edge_chan_princ->GetLastFunction()->SetDescription(""); - - Handle(GEOM_Object) edge_chan_inc = myBlocksOperations->GetEdge(theShape, P2, P4); - if (edge_chan_inc.IsNull()) { - SetErrorCode("Impossible to find edge on incident pipe"); - return false; - } - edge_chan_inc->GetLastFunction()->SetDescription(""); - - std::list edgeList1; - edgeList1.push_back(edge_chan_princ); - edgeList1.push_back(Cote_1); - edgeList1.push_back(arete_intersect_int); - edgeList1.push_back(Cote_2); - - // std::cerr << "Creating wire 1" << std::endl; - wire_t = myShapesOperations->MakeWire(edgeList1, 1e-7); - if (wire_t.IsNull()) { - SetErrorCode("Impossible to build wire"); - return false; - } - wire_t->GetLastFunction()->SetDescription(""); - - // std::cerr << "Creating face 1" << std::endl; - face_t = myShapesOperations->MakeFace(wire_t, false); - if (face_t.IsNull()) { - SetErrorCode("Impossible to build face"); - return false; - } - face_t->GetLastFunction()->SetDescription(""); - theShapes.push_back(face_t); - - gp_Pnt aP2 = BRep_Tool::Pnt(TopoDS::Vertex(P2->GetValue())); - gp_Pnt aP5 = BRep_Tool::Pnt(TopoDS::Vertex(vi1->GetValue())); - double deltaZ = aP2.Z() - aP5.Z(); - // std::cerr << "Creating new point from vi1 with deltaZ = " << deltaZ << std::endl; - Handle(GEOM_Object) P5bis = myTransformOperations->TranslateDXDYDZCopy(vi1, 0, 0, deltaZ); - if (P5bis.IsNull()) { - SetErrorCode("Impossible to translate vertex"); - return false; - } - P5bis->GetLastFunction()->SetDescription(""); - - gp_Pnt aP4 = BRep_Tool::Pnt(TopoDS::Vertex(P4->GetValue())); - gp_Pnt aP6 = BRep_Tool::Pnt(TopoDS::Vertex(vi2->GetValue())); - deltaZ = aP4.Z() - aP6.Z(); - // std::cerr << "Creating new point from vi2 with deltaZ = " << deltaZ << std::endl; - Handle(GEOM_Object) P6bis = myTransformOperations->TranslateDXDYDZCopy(vi2, 0, 0, deltaZ); - if (P6bis.IsNull()) { - SetErrorCode("Impossible to translate vertex"); - return false; - } - P6bis->GetLastFunction()->SetDescription(""); - - // std::cerr << "Creating new line 1 from 2 previous points" << std::endl; - Handle(GEOM_Object) Cote_3 = myBasicOperations->MakeLineTwoPnt(P5bis, P2); - if (Cote_3.IsNull()) { - SetErrorCode("Impossible to build edge in thickness"); - return false; - } - Cote_3->GetLastFunction()->SetDescription(""); - - // std::cerr << "Creating new line 2 from 2 previous points" << std::endl; - Handle(GEOM_Object) Cote_4 = myBasicOperations->MakeLineTwoPnt(P6bis, P4); - if (Cote_4.IsNull()) { - SetErrorCode("Impossible to build edge in thickness"); - return false; - } - Cote_4->GetLastFunction()->SetDescription(""); - - // std::cerr << "Creating new line 3 from 2 previous points" << std::endl; - Handle(GEOM_Object) Cote_5 = myBasicOperations->MakeLineTwoPnt(P5bis, P6bis); - if (Cote_4.IsNull()) { - SetErrorCode("Impossible to build edge in thickness"); - return false; - } - Cote_5->GetLastFunction()->SetDescription(""); - - //std::list edgeList2; - //edgeList2.push_back(edge_chan_inc); - //edgeList2.push_back(Cote_3); - //edgeList2.push_back(Cote_5); - //edgeList2.push_back(Cote_4); - // std::cerr << "Creating wire 2" << std::endl; - //wire_t2 = myShapesOperations->MakeWire(edgeList2, 1e-7); - //if (wire_t2.IsNull()) { - // SetErrorCode("Impossible to build wire"); - // return false; - //} - //wire_t2->GetLastFunction()->SetDescription(""); - // std::cerr << "Creating face 2" << std::endl; - //face_t2 = myShapesOperations->MakeFace(wire_t2, false); - - // Mantis issue 0021682 - face_t2 = my3DPrimOperations->MakePrismVecH(edge_chan_inc, Cote_4, - (theR2 + theW2)); - //face_t2 = my3DPrimOperations->MakePrismVecH(edge_chan_inc, Cote_4, - 2.0*theR2); - if (face_t2.IsNull()) { - SetErrorCode("Impossible to build face"); - return false; - } - face_t2->GetLastFunction()->SetDescription(""); - theShapes.push_back(face_t2); - } - - // Planes - Handle(GEOM_Object) aP0 = myBasicOperations->MakePointXYZ(0, 0, 0); - Handle(GEOM_Object) aVZ = myBasicOperations->MakeVectorDXDYDZ(0, 0, 1); - Handle(GEOM_Object) aVXZ = myBasicOperations->MakeVectorDXDYDZ(aR1Ext, 0, 0.5*(theL1+theVertCylinderRadius)); - Handle(GEOM_Object) aPlnOZ = myBasicOperations->MakePlanePntVec(aP0, aVZ, aSize); - Handle(GEOM_Object) aPlnOXZ = myBasicOperations->MakePlanePntVec(aP0, aVXZ, aSize); - aP0->GetLastFunction()->SetDescription(""); - aVZ->GetLastFunction()->SetDescription(""); - aVXZ->GetLastFunction()->SetDescription(""); - aPlnOZ->GetLastFunction()->SetDescription(""); - aPlnOXZ->GetLastFunction()->SetDescription(""); - theShapes.push_back(aPlnOZ); - theShapes.push_back(aPlnOXZ); - - // Partition - Handle(TColStd_HSequenceOfTransient) partitionShapes = new TColStd_HSequenceOfTransient; - Handle(TColStd_HSequenceOfTransient) theTools = new TColStd_HSequenceOfTransient; - Handle(TColStd_HSequenceOfTransient) theKeepInside = new TColStd_HSequenceOfTransient; - Handle(TColStd_HSequenceOfTransient) theRemoveInside = new TColStd_HSequenceOfTransient; - Handle(TColStd_HArray1OfInteger) theMaterials; - - partitionShapes->Append(theShape); - theTools->Append(aPlnOZ); - if (Abs(aR1Ext - aR2Ext) > Precision::Confusion()) - theTools->Append(aPlnOXZ); - theTools->Append(face_t); - if (!isNormal) - theTools->Append(face_t2); - - Te3 = myBooleanOperations->MakePartition - (partitionShapes, theTools, theKeepInside, theRemoveInside, - TopAbs_SOLID, false, theMaterials, 0, false); - if (Te3.IsNull()) { - SetErrorCode("Impossible to build partition of TShape"); - return false; - } - Te3->GetLastFunction()->SetDescription(""); - - // Last verification: result should be a block - std::list errList; - if (!myBlocksOperations->CheckCompoundOfBlocks(Te3,errList)) { - SetErrorCode("TShape is not a compound of block"); - return false; - } - -// // BEGIN Compound of created shapes - Only for debug purpose -// theShapes.clear(); -// theShapes.push_back(theShape); -// theShapes.push_back(aPlnOZ); -// if (Abs(aR1Ext - aR2Ext) > Precision::Confusion() ) -// theShapes.push_back(aPlnOXZ); -// theShapes.push_back(face_t); -// if (!isNormal) -// theShapes.push_back(face_t2); -// -// Handle(GEOM_Object) aCompound = myShapesOperations->MakeCompound(theShapes); -// TopoDS_Shape aCompoundShape = aCompound->GetValue(); -// theShape->GetLastFunction()->SetValue(aCompoundShape); -// // END Compound of created shapes - Only for debug purpose - - TopoDS_Shape aShape = Te3->GetValue(); - theShape->GetLastFunction()->SetValue(aShape); - } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - SetErrorCode(aFail->GetMessageString()); - return false; - } - - SetErrorCode(OK); - return true; -} - -// Mirror and glue faces -bool GEOMImpl_IAdvancedOperations::MakePipeTShapeMirrorAndGlue(Handle(GEOM_Object) theShape, - double theR1, double theW1, double theL1, - double theR2, double theW2, double theL2) -{ - SetErrorCode(KO); - - // Useful values - double aSize = 2*(theL1 + theL2); - double aR1Ext = theR1 + theW1; - - // Planes - Handle(GEOM_Object) aP0 = myBasicOperations->MakePointXYZ(0, 0, 0); - aP0->GetLastFunction()->SetDescription(""); - Handle(GEOM_Object) aVX = myBasicOperations->MakeVectorDXDYDZ(1, 0, 0); - Handle(GEOM_Object) aVY = myBasicOperations->MakeVectorDXDYDZ(0, 1, 0); - aVX->GetLastFunction()->SetDescription(""); - aVY->GetLastFunction()->SetDescription(""); - Handle(GEOM_Object) aPlane_OX = myBasicOperations->MakePlanePntVec(aP0, aVX, 2*(aR1Ext + theL2)); - Handle(GEOM_Object) aPlane_OY = myBasicOperations->MakePlanePntVec(aP0, aVY, aSize); - aPlane_OX->GetLastFunction()->SetDescription(""); - aPlane_OY->GetLastFunction()->SetDescription(""); - - Handle(GEOM_Object) Te4 = myTransformOperations->MirrorPlaneCopy(theShape, aPlane_OX); - if (Te4.IsNull()) { - SetErrorCode("Impossible to build mirror of quarter TShape"); - return false; - } - - Handle(GEOM_Object) Te5 = myTransformOperations->MirrorPlaneCopy(theShape, aPlane_OY); - if (Te5.IsNull()) { - SetErrorCode("Impossible to build mirror of half TShape"); - return false; - } - - Handle(GEOM_Object) Te6 = myTransformOperations->MirrorPlaneCopy(Te4, aPlane_OY); - if (Te6.IsNull()) { - SetErrorCode("Impossible to build mirror of half TShape"); - return false; - } - - std::list aShapesList; - aShapesList.push_back(theShape); - aShapesList.push_back(Te4); - aShapesList.push_back(Te5); - aShapesList.push_back(Te6); - Handle(GEOM_Object) Te7 = myShapesOperations->MakeCompound(aShapesList); - if (Te7.IsNull()) { - SetErrorCode("Impossible to build compound"); - return false; - } - - // Copy source shape - TopoDS_Shape aShapeCopy; - TColStd_IndexedDataMapOfTransientTransient aMapTShapes; - TNaming_CopyShape::CopyTool(Te7->GetValue(), aMapTShapes, aShapeCopy); - - Handle(GEOM_Object) Te8 = myShapesOperations->MakeGlueFaces(Te7, 1e-7, true); - if (Te8.IsNull()) { - SetErrorCode("Impossible to glue faces of TShape"); - return false; - } - - TopoDS_Shape aShape = Te8->GetValue(); - BRepCheck_Analyzer anAna (aShape, Standard_True); - - if (!anAna.IsValid()) { - // Try to do gluing with the tolerance equal to maximal - // tolerance of vertices of the source shape. - Standard_Real aTolMax = -RealLast(); - - for (TopExp_Explorer ExV (aShapeCopy, TopAbs_VERTEX); ExV.More(); ExV.Next()) { - TopoDS_Vertex aVertex = TopoDS::Vertex(ExV.Current()); - Standard_Real aTol = BRep_Tool::Tolerance(aVertex); - - if (aTol > aTolMax) { - aTolMax = aTol; - } - } - - // Perform gluing - Te7->GetLastFunction()->SetValue(aShapeCopy); - Te8 = myShapesOperations->MakeGlueFaces(Te7, aTolMax, true); - - if (Te8.IsNull()) { - SetErrorCode("Impossible to glue faces of TShape"); - return false; - } - - aShape = Te8->GetValue(); - } - - - theShape->GetLastFunction()->SetValue(aShape); - - Te4->GetLastFunction()->SetDescription(""); - Te5->GetLastFunction()->SetDescription(""); - Te6->GetLastFunction()->SetDescription(""); - Te7->GetLastFunction()->SetDescription(""); - Te8->GetLastFunction()->SetDescription(""); - - SetErrorCode(OK); - return true; -} - -//======================================================================= -//function : MakePipeTShapeThicknessReduction -//purpose : Static method. Add thiskness reduction elements at the three -// open ends of the T-Shape. -//======================================================================= -TopoDS_Shape GEOMImpl_IAdvancedOperations::MakePipeTShapeThicknessReduction - (TopoDS_Shape theShape, - double r1, double w1, double l1, - double r2, double w2, double l2, - double rL, double wL, double ltransL, double lthinL, - double rR, double wR, double ltransR, double lthinR, - double rI, double wI, double ltransI, double lthinI, - bool fuseReductions) -{ - // Add thickness reduction elements - // at the three extremities: Left, Right and Incident - // - // ---------------------. - // W \ - // ---------------------. \ - // ^ \ '-----------------. - // |R \ Wthin | - // | '-----------------' - // v Rthin - // --.--.--.--.--.--.--.--.--.--.--.--.--.--.-- - // Ltrans Lthin - - TopoDS_Shape aResult = theShape; - double aTol = Precision::Confusion(); - - gp_Vec aVX = gp::DX(), aVZ = gp::DZ(); - - // Left reduction (rL, wL, ltransL, lthinL) - if (rL > aTol && wL > aTol && ltransL > aTol) { - gp_Pnt aPLeft (-l1, 0, 0); - gp_Ax2 anAxesLeft (aPLeft, -aVX, aVZ); - TopoDS_Shape aReductionLeft = GEOMImpl_IAdvancedOperations::MakeThicknessReduction - (anAxesLeft, r1, w1, rL, wL, ltransL, lthinL, fuseReductions); - - if (fuseReductions) { - BRepAlgoAPI_Fuse fuseL (aResult, aReductionLeft); - if (!fuseL.IsDone()) - StdFail_NotDone::Raise("Cannot fuse Te with left reduction"); - aResult = fuseL.Shape(); - } - else { - BRep_Builder B; - TopoDS_Compound C; - B.MakeCompound(C); - B.Add(C, aResult); - B.Add(C, aReductionLeft); - aResult = C; - } - } - - // Right reduction - if (rR > aTol && wR > aTol && ltransR > aTol) { - gp_Pnt aPRight (l1, 0, 0); - gp_Ax2 anAxesRight (aPRight, aVX, aVZ); - TopoDS_Shape aReductionRight = GEOMImpl_IAdvancedOperations::MakeThicknessReduction - (anAxesRight, r1, w1, rR, wR, ltransR, lthinR, fuseReductions); - - if (fuseReductions) { - BRepAlgoAPI_Fuse fuseR (aResult, aReductionRight); - if (!fuseR.IsDone()) - StdFail_NotDone::Raise("Cannot fuse Te with right reduction"); - aResult = fuseR.Shape(); - } - else { - BRep_Builder B; - TopoDS_Compound C; - B.MakeCompound(C); - B.Add(C, aResult); - B.Add(C, aReductionRight); - aResult = C; - } - } - - // Incident reduction - if (rI > aTol && wI > aTol && ltransI > aTol) { - gp_Pnt aPInci (0, 0, l2); - gp_Ax2 anAxesInci (aPInci, aVZ, aVX); - TopoDS_Shape aReductionInci = GEOMImpl_IAdvancedOperations::MakeThicknessReduction - (anAxesInci, r2, w2, rI, wI, ltransI, lthinI, fuseReductions); - - if (fuseReductions) { - BRepAlgoAPI_Fuse fuseInci (aResult, aReductionInci); - if (!fuseInci.IsDone()) - StdFail_NotDone::Raise("Cannot fuse Te with incident reduction"); - aResult = fuseInci.Shape(); - } - else { - BRep_Builder B; - TopoDS_Compound C; - B.MakeCompound(C); - B.Add(C, aResult); - B.Add(C, aReductionInci); - aResult = C; - } - } - - // Get rid of extra compounds - TopTools_ListOfShape listShapeRes; - GEOMUtils::AddSimpleShapes(aResult, listShapeRes); - aResult = listShapeRes.First(); // useful for the case "fuseReductions == true" - - if (!fuseReductions && listShapeRes.Extent() > 1) { - // Simplify T-Shape compound (get rid of sub-compounds) and glue duplicated faces - BRep_Builder B; - TopoDS_Compound C; - B.MakeCompound(C); - - TopTools_ListIteratorOfListOfShape itSub (listShapeRes); - for (; itSub.More(); itSub.Next()) - B.Add(C, itSub.Value()); - - // GlueFaces - aResult = GEOMImpl_GlueDriver::GlueFaces(C, Precision::Confusion(), Standard_True); - } - - return aResult; -} - -//======================================================================= -//function : MakeThicknessReduction -//purpose : Static method. Create one thickness reduction element. -//======================================================================= -TopoDS_Shape GEOMImpl_IAdvancedOperations::MakeThicknessReduction (gp_Ax2 theAxes, - const double R, const double W, - const double Rthin, const double Wthin, - const double Ltrans, const double Lthin, - bool fuse) -{ - double aTol = Precision::Confusion(); - if (Rthin < aTol || Wthin < aTol || Ltrans < aTol) { - StdFail_NotDone::Raise("Cannot build thickness reduction: too small values"); - } - bool isThinPart = (Lthin > aTol); - - // . - // W |\ - // . \ - // ^ \ '-----------------. - // |R \| | Wthin - // | '-----------------' - // v Rthin - // --.--.--.--.--.--.--.--.--.--.--.--.--> theAxes.Direction() - // Ltrans Lthin - - double RExt = R + W; - double RthinExt = Rthin + Wthin; - - gp_Dir aNormal = theAxes.Direction(); - gp_Dir anXDir = theAxes.XDirection(); - gp_Pnt aPntCyl (theAxes.Location().XYZ() + aNormal.XYZ()*Ltrans); - gp_Ax2 anAxesCyl (aPntCyl, aNormal, anXDir); - - // Build the transition part - BRepPrimAPI_MakeCone ConeExt (theAxes, RExt, RthinExt, Ltrans); - BRepPrimAPI_MakeCone ConeInt (theAxes, R, Rthin, Ltrans); - ConeExt.Build(); - ConeInt.Build(); - if (!ConeExt.IsDone() || !ConeInt.IsDone()) - StdFail_NotDone::Raise("Cannot build cones of thickness reduction"); - BRepAlgoAPI_Cut cut1 (ConeExt.Shape(), ConeInt.Shape()); - if (!cut1.IsDone()) - StdFail_NotDone::Raise("Coudn't build transition part of thickness reduction"); - TopoDS_Shape aReduction = cut1.Shape(); - - // Build the thin part, if required - TopoDS_Shape aThinPart; - if (isThinPart) { - BRepPrimAPI_MakeCylinder CExt (anAxesCyl, RthinExt, Lthin); - BRepPrimAPI_MakeCylinder CInt (anAxesCyl, Rthin, Lthin); - CExt.Build(); - CInt.Build(); - if (!CExt.IsDone() || !CInt.IsDone()) - StdFail_NotDone::Raise("Cannot build cylinders of thickness reduction"); - BRepAlgoAPI_Cut cut2 (CExt.Shape(), CInt.Shape()); - if (!cut2.IsDone()) - StdFail_NotDone::Raise("Coudn't build thin part of thickness reduction"); - aThinPart = cut2.Shape(); - } - - // Join parts - if (fuse) { - if (isThinPart) { - BRepAlgoAPI_Fuse fuse1 (aReduction, aThinPart); - if (!fuse1.IsDone()) - StdFail_NotDone::Raise("Cannot fuse parts of thickness reduction"); - aReduction = fuse1.Shape(); - } - } - else { - // Partition the reduction on blocks - gp_Ax3 anAxesPln1 (aPntCyl, theAxes.XDirection(), aNormal); - gp_Ax3 anAxesPln2 (aPntCyl, theAxes.YDirection(), aNormal); - gp_Pln aPln1 (anAxesPln1); - gp_Pln aPln2 (anAxesPln2); - double aSize = Ltrans + Lthin + R + Rthin + Wthin; // to guarantee enough size in all directions - TopoDS_Shape aTool1 = BRepBuilderAPI_MakeFace(aPln1, -aSize, +aSize, -aSize, +aSize).Shape(); - TopoDS_Shape aTool2 = BRepBuilderAPI_MakeFace(aPln2, -aSize, +aSize, -aSize, +aSize).Shape(); - - GEOMAlgo_Splitter PS; - PS.AddShape(aReduction); - if (isThinPart) - PS.AddShape(aThinPart); - PS.AddTool(aTool1); - PS.AddTool(aTool2); - PS.SetLimit(TopAbs_SOLID); - PS.Perform(); - - aReduction = PS.Shape(); - } - - return aReduction; -} - -//============================================================================= -/*! - * MakePipeTShape - * \brief Create a T-shape object with specified caracteristics for the main and - * the incident pipes (radius, width, half-length). - * Center of the shape is (0,0,0). The main plane of the T-shape is XOY. - * \param theR1 Internal radius of main pipe - * \param theW1 Width of main pipe - * \param theL1 Half-length of main pipe - * \param theR2 Internal radius of incident pipe (R2 < R1) - * \param theW2 Width of incident pipe (R2+W2 < R1+W1) - * \param theL2 Half-length of incident pipe - * \param theHexMesh Boolean indicating if shape is prepared for hex mesh - * \return List of GEOM_Objects, containing the created shape and propagation groups. - */ -//============================================================================= -Handle(TColStd_HSequenceOfTransient) - GEOMImpl_IAdvancedOperations::MakePipeTShape(double theR1, double theW1, double theL1, - double theR2, double theW2, double theL2, - double theRL, double theWL, double theLtransL, double theLthinL, - double theRR, double theWR, double theLtransR, double theLthinR, - double theRI, double theWI, double theLtransI, double theLthinI, - bool theHexMesh) -{ - MESSAGE("GEOMImpl_IAdvancedOperations::MakePipeTShape"); - SetErrorCode(KO); - //Add a new object - Handle(GEOM_Object) aShape = GetEngine()->AddObject(GetDocID(), GEOM_TSHAPE); - - //Add a new shape function with parameters - Handle(GEOM_Function) aFunction = aShape->AddFunction(GEOMImpl_PipeTShapeDriver::GetID(), TSHAPE_BASIC); - if (aFunction.IsNull()) return NULL; - - //Check if the function is set correctly - if (aFunction->GetDriverGUID() != GEOMImpl_PipeTShapeDriver::GetID()) return NULL; - - GEOMImpl_IPipeTShape aData (aFunction); - - aData.SetR1(theR1); - aData.SetW1(theW1); - aData.SetL1(theL1); - aData.SetR2(theR2); - aData.SetW2(theW2); - aData.SetL2(theL2); - aData.SetHexMesh(theHexMesh); - - bool isTRL = (theRL + theWL + theLtransL + theLthinL) > Precision::Confusion(); - bool isTRR = (theRR + theWR + theLtransR + theLthinR) > Precision::Confusion(); - bool isTRI = (theRI + theWI + theLtransI + theLthinI) > Precision::Confusion(); - - //Compute the resulting value - try { -#if OCC_VERSION_LARGE > 0x06010000 - OCC_CATCH_SIGNALS; -#endif - if (!GetSolver()->ComputeFunction(aFunction)) { - SetErrorCode("TShape driver failed"); - return NULL; - } - - if (theHexMesh) { - if (!MakePipeTShapePartition(aShape, theR1, theW1, theL1, theR2, theW2, theL2)) - return NULL; - if (!MakePipeTShapeMirrorAndGlue(aShape, theR1, theW1, theL1, theR2, theW2, theL2)) - return NULL; - } - - if (isTRL || isTRR || isTRI) { - // Add thickness reduction elements - // at the three extremities: Left, Right and Incident - TopoDS_Shape aResShape = - MakePipeTShapeThicknessReduction(aShape->GetValue(), theR1, theW1, theL1, theR2, theW2, theL2, - theRL, theWL, theLtransL, theLthinL, - theRR, theWR, theLtransR, theLthinR, - theRI, theWI, theLtransI, theLthinI, - !theHexMesh); - aFunction->SetValue(aResShape); - } - } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - SetErrorCode(aFail->GetMessageString()); - return NULL; - } - - Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient; - aSeq->Append(aShape); - - try { - if (theHexMesh) { - // Get the groups - if (!MakeGroups(aShape, TSHAPE_BASIC, theR1, theW1, theL1, theR2, theW2, theL2, - 0., 0., 0., aSeq, gp_Trsf())) - return NULL; - } - - // Get internal group. - if (!MakeInternalGroup(aShape, theR1, theL1, theR2, theL2, theRL, theLtransL, - theRR, theLtransR, theRI, theLtransI, - aSeq, gp_Trsf())) { - return NULL; - } - } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - SetErrorCode(aFail->GetMessageString()); - return NULL; - } - - //Make a Python command - TCollection_AsciiString anEntry, aListRes("["); - // Iterate over the sequence aSeq - Standard_Integer aNbGroups = aSeq->Length(); - Standard_Integer i = 1; - for (; i <= aNbGroups; i++) { - Handle(Standard_Transient) anItem = aSeq->Value(i); - if (anItem.IsNull()) continue; - Handle(GEOM_Object) aGroup = Handle(GEOM_Object)::DownCast(anItem); - if (aGroup.IsNull()) continue; - //Make a Python command - TDF_Tool::Entry(aGroup->GetEntry(), anEntry); - aListRes += anEntry + ", "; - } - aListRes.Trunc(aListRes.Length() - 2); - - GEOM::TPythonDump pd (aFunction); - - pd << aListRes.ToCString() << "] = geompy.MakePipeTShape(" - << theR1 << ", " << theW1 << ", " << theL1 << ", " - << theR2 << ", " << theW2 << ", " << theL2 << ", " - << theHexMesh; - - // thickness reduction - if (isTRL) - pd << ", theRL=" << theRL << ", theWL=" << theWL - << ", theLtransL=" << theLtransL << ", theLthinL=" << theLthinL; - if (isTRR) - pd << ", theRR=" << theRR << ", theWR=" << theWR - << ", theLtransR=" << theLtransR << ", theLthinR=" << theLthinR; - if (isTRI) - pd << ", theRI=" << theRI << ", theWI=" << theWI - << ", theLtransI=" << theLtransI << ", theLthinI=" << theLthinI; - - pd << ")"; - - SetErrorCode(OK); - - return aSeq; -} - -//============================================================================= -/*! - * MakePipeTShapeWithPosition - * Create a T-shape object with specified caracteristics for the main and - * the incident pipes (radius, width, half-length). - * The extremities of the main pipe are located on junctions points P1 and P2. - * The extremity of the incident pipe is located on junction point P3. - * \param theR1 Internal radius of main pipe - * \param theW1 Width of main pipe - * \param theL1 Half-length of main pipe - * \param theR2 Internal radius of incident pipe (R2 < R1) - * \param theW2 Width of incident pipe (R2+W2 < R1+W1) - * \param theL2 Half-length of incident pipe - * \param theHexMesh Boolean indicating if shape is prepared for hex mesh - * \param theP1 1st junction point of main pipe - * \param theP2 2nd junction point of main pipe - * \param theP3 Junction point of incident pipe - * \return List of GEOM_Objects, containing the created shape and propagation groups.. - */ -//============================================================================= -Handle(TColStd_HSequenceOfTransient) -GEOMImpl_IAdvancedOperations::MakePipeTShapeWithPosition - (double theR1, double theW1, double theL1, - double theR2, double theW2, double theL2, - double theRL, double theWL, double theLtransL, double theLthinL, - double theRR, double theWR, double theLtransR, double theLthinR, - double theRI, double theWI, double theLtransI, double theLthinI, - bool theHexMesh, - Handle(GEOM_Object) theP1, - Handle(GEOM_Object) theP2, - Handle(GEOM_Object) theP3) -{ - SetErrorCode(KO); - //Add a new object - Handle(GEOM_Object) aShape = GetEngine()->AddObject(GetDocID(), GEOM_TSHAPE); - ///////////////// - // TSHAPE CODE - ///////////////// - //Add a new shape function with parameters - Handle(GEOM_Function) aFunction = aShape->AddFunction(GEOMImpl_PipeTShapeDriver::GetID(), TSHAPE_BASIC); - if (aFunction.IsNull()) return NULL; - - //Check if the function is set correctly - if (aFunction->GetDriverGUID() != GEOMImpl_PipeTShapeDriver::GetID()) return NULL; - - // Check new position - if (!CheckCompatiblePosition(theL1, theL2, theP1, theP2, theP3, 0.01)) { - return NULL; - } - - GEOMImpl_IPipeTShape aData(aFunction); - - aData.SetR1(theR1); - aData.SetW1(theW1); - aData.SetL1(theL1); - aData.SetR2(theR2); - aData.SetW2(theW2); - aData.SetL2(theL2); - aData.SetHexMesh(theHexMesh); - - bool isTRL = (theRL + theWL + theLtransL + theLthinL) > Precision::Confusion(); - bool isTRR = (theRR + theWR + theLtransR + theLthinR) > Precision::Confusion(); - bool isTRI = (theRI + theWI + theLtransI + theLthinI) > Precision::Confusion(); - - //Compute the resulting value - try { -#if OCC_VERSION_LARGE > 0x06010000 - OCC_CATCH_SIGNALS; -#endif - if (!GetSolver()->ComputeFunction(aFunction)) { - SetErrorCode("TShape driver failed"); - return NULL; - } - - if (theHexMesh) { - if (!MakePipeTShapePartition(aShape, theR1, theW1, theL1, theR2, theW2, theL2)) - return NULL; - if (!MakePipeTShapeMirrorAndGlue(aShape, theR1, theW1, theL1, theR2, theW2, theL2)) - return NULL; - } - - if (isTRL || isTRR || isTRI) { - // Add thickness reduction elements - // at the three extremities: Left, Right and Incident - TopoDS_Shape aResShape = - MakePipeTShapeThicknessReduction(aShape->GetValue(), theR1, theW1, theL1, theR2, theW2, theL2, - theRL, theWL, theLtransL, theLthinL, - theRR, theWR, theLtransR, theLthinR, - theRI, theWI, theLtransI, theLthinI, - !theHexMesh); - aFunction->SetValue(aResShape); - } - } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - SetErrorCode(aFail->GetMessageString()); - return NULL; - } - - TopoDS_Shape Te = aShape->GetValue(); - - // Set Position - gp_Trsf aTrsf = GetPositionTrsf(theL1, theL2, theP1, theP2, theP3); - BRepBuilderAPI_Transform aTransformation(Te, aTrsf, Standard_False); - TopoDS_Shape aTrsf_Shape = aTransformation.Shape(); - aFunction->SetValue(aTrsf_Shape); - - Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient; - aSeq->Append(aShape); - - try { - if (theHexMesh) { - // Get the groups - if (!MakeGroups(aShape,TSHAPE_BASIC, theR1, theW1, theL1, theR2, theW2, theL2, - 0., 0., 0., aSeq, aTrsf)) { - return NULL; - } - } - - // Get internal group. - if (!MakeInternalGroup(aShape, theR1, theL1, theR2, theL2, theRL, theLtransL, - theRR, theLtransR, theRI, theLtransI, - aSeq, aTrsf)) { - return NULL; - } - } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - SetErrorCode(aFail->GetMessageString()); - return NULL; - } - - //Make a Python command - TCollection_AsciiString anEntry, aListRes("["); - // Iterate over the sequence aSeq - Standard_Integer aNbGroups = aSeq->Length(); - Standard_Integer i = 1; - for (; i <= aNbGroups; i++) { - Handle(Standard_Transient) anItem = aSeq->Value(i); - if (anItem.IsNull()) continue; - Handle(GEOM_Object) aGroup = Handle(GEOM_Object)::DownCast(anItem); - if (aGroup.IsNull()) continue; - //Make a Python command - TDF_Tool::Entry(aGroup->GetEntry(), anEntry); - aListRes += anEntry + ", "; - } - aListRes.Trunc(aListRes.Length() - 2); - - GEOM::TPythonDump pd (aFunction); - - pd << aListRes.ToCString() << "] = geompy.MakePipeTShape(" - << theR1 << ", " << theW1 << ", " << theL1 << ", " - << theR2 << ", " << theW2 << ", " << theL2 << ", " - << theHexMesh << ", " << theP1 << ", " << theP2 << ", " << theP3; - - // thickness reduction - if (isTRL) - pd << ", theRL=" << theRL << ", theWL=" << theWL - << ", theLtransL=" << theLtransL << ", theLthinL=" << theLthinL; - if (isTRR) - pd << ", theRR=" << theRR << ", theWR=" << theWR - << ", theLtransR=" << theLtransR << ", theLthinR=" << theLthinR; - if (isTRI) - pd << ", theRI=" << theRI << ", theWI=" << theWI - << ", theLtransI=" << theLtransI << ", theLthinI=" << theLthinI; - - pd << ")"; - - SetErrorCode(OK); - - return aSeq; -} - -//============================================================================= -/*! - * MakePipeTShapeChamfer - * Create a T-shape object with specified caracteristics for the main and - * the incident pipes (radius, width, half-length). A chamfer is created - * on the junction of the pipes. - * Center of the shape is (0,0,0). The main plane of the T-shape is XOY. - * \param theR1 Internal radius of main pipe - * \param theW1 Width of main pipe - * \param theL1 Half-length of main pipe - * \param theR2 Internal radius of incident pipe (R2 < R1) - * \param theW2 Width of incident pipe (R2+W2 < R1+W1) - * \param theL2 Half-length of incident pipe - * \param theH Height of chamfer. - * \param theW Width of chamfer. - * \param theHexMesh Boolean indicating if shape is prepared for hex mesh - * \return List of GEOM_Objects, containing the created shape and propagation groups. - */ -//============================================================================= -Handle(TColStd_HSequenceOfTransient) -GEOMImpl_IAdvancedOperations::MakePipeTShapeChamfer - (double theR1, double theW1, double theL1, - double theR2, double theW2, double theL2, - double theRL, double theWL, double theLtransL, double theLthinL, - double theRR, double theWR, double theLtransR, double theLthinR, - double theRI, double theWI, double theLtransI, double theLthinI, - double theH, double theW, - bool theHexMesh) -{ - SetErrorCode(KO); - //Add a new object - Handle(GEOM_Object) aShape = GetEngine()->AddObject(GetDocID(), GEOM_TSHAPE); - //Add a new shape function with parameters - Handle(GEOM_Function) aFunction = aShape->AddFunction(GEOMImpl_PipeTShapeDriver::GetID(), TSHAPE_CHAMFER); - if (aFunction.IsNull()) return NULL; - - //Check if the function is set correctly - if (aFunction->GetDriverGUID() != GEOMImpl_PipeTShapeDriver::GetID()) return NULL; - - GEOMImpl_IPipeTShape aData(aFunction); - - aData.SetR1(theR1); - aData.SetW1(theW1); - aData.SetL1(theL1); - aData.SetR2(theR2); - aData.SetW2(theW2); - aData.SetL2(theL2); - aData.SetH(theH); - aData.SetW(theW); - aData.SetHexMesh(theHexMesh); - - bool isTRL = (theRL + theWL + theLtransL + theLthinL) > Precision::Confusion(); - bool isTRR = (theRR + theWR + theLtransR + theLthinR) > Precision::Confusion(); - bool isTRI = (theRI + theWI + theLtransI + theLthinI) > Precision::Confusion(); - - //Compute the resulting value - try { -#if OCC_VERSION_LARGE > 0x06010000 - OCC_CATCH_SIGNALS; -#endif - if (!GetSolver()->ComputeFunction(aFunction)) { - SetErrorCode("TShape driver failed"); - return NULL; - } - } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - SetErrorCode(aFail->GetMessageString()); - return NULL; - } - - // BEGIN of chamfer - TopoDS_Shape aShapeShape = aShape->GetValue(); - TopTools_IndexedMapOfShape anEdgesIndices; - TopExp::MapShapes(aShapeShape, anEdgesIndices); - // Common edges on external cylinders - Handle(GEOM_Object) box_e; - if (theHexMesh) { - box_e = my3DPrimOperations->MakeBoxDXDYDZ(theR2+theW2, theR2+theW2, theR1+theW1); - } - else { - box_e = my3DPrimOperations->MakeBoxDXDYDZ(2*(theR2+theW2), 2*(theR2+theW2), theR1+theW1); - } - box_e->GetLastFunction()->SetDescription(""); - box_e = myTransformOperations->TranslateDXDYDZ(box_e, -(theR2+theW2), -(theR2+theW2), 0); - box_e->GetLastFunction()->SetDescription(""); - - Handle(TColStd_HSequenceOfInteger) edges_e = - myShapesOperations->GetShapesOnBoxIDs(box_e, aShape, TopAbs_EDGE, GEOMAlgo_ST_IN); - box_e->GetLastFunction()->SetDescription(""); - - if (edges_e.IsNull() || edges_e->Length() == 0) { - SetErrorCode("External edges not found"); - return NULL; - } - int nbEdgesInChamfer = 0; - std::list theEdges; - for (int i=1; i<=edges_e->Length();i++) { - int edgeID = edges_e->Value(i); - TopoDS_Shape theEdge = anEdgesIndices.FindKey(edgeID); - TopExp_Explorer Ex(theEdge,TopAbs_VERTEX); - int iv=0; - while (Ex.More()) { - iv ++; - gp_Pnt aPt = BRep_Tool::Pnt(TopoDS::Vertex(Ex.Current())); - if (Abs(aPt.Z() - (theR1+theW1)) <= Precision::Confusion()) { - nbEdgesInChamfer ++; - theEdges.push_back(edgeID); - } - Ex.Next(); - } - if (theHexMesh && nbEdgesInChamfer == 1) - break; - } - Handle(GEOM_Object) aChamfer; - try { - aChamfer = myLocalOperations->MakeChamferEdges(aShape, theW, theH, theEdges); - } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - SetErrorCode(aFail->GetMessageString()); - return NULL; - } - if (aChamfer.IsNull()) { - SetErrorCode("Chamfer can not be computed on the given shape with the given parameters"); - return NULL; - } - aChamfer->GetLastFunction()->SetDescription(""); - - TopoDS_Shape aChamferShape = aChamfer->GetValue(); - aFunction->SetValue(aChamferShape); - // END of chamfer - - if (theHexMesh) { - if (!MakePipeTShapePartition(aShape, theR1, theW1, theL1, theR2, theW2, theL2, theH, theW, 0, false)) - return NULL; - if (!MakePipeTShapeMirrorAndGlue(aShape, theR1, theW1, theL1, theR2, theW2, theL2)) - return NULL; - } - - // Add thickness reduction elements - // at the three extremities: Left, Right and Incident - try { -#if OCC_VERSION_LARGE > 0x06010000 - OCC_CATCH_SIGNALS; -#endif - if (isTRL || isTRR || isTRI) { - TopoDS_Shape aResShape = - MakePipeTShapeThicknessReduction(aShape->GetValue(), theR1, theW1, theL1, theR2, theW2, theL2, - theRL, theWL, theLtransL, theLthinL, - theRR, theWR, theLtransR, theLthinR, - theRI, theWI, theLtransI, theLthinI, - !theHexMesh); - aFunction->SetValue(aResShape); - } - } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - SetErrorCode(aFail->GetMessageString()); - return NULL; - } - - Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient; - aSeq->Append(aShape); - - try { - if (theHexMesh) { - // Get the groups - if (!MakeGroups(aShape, TSHAPE_CHAMFER, theR1, theW1, theL1, theR2, theW2, theL2, - theH, theW, 0., aSeq, gp_Trsf())) - return NULL; - } - - // Get internal group. - if (!MakeInternalGroup(aShape, theR1, theL1, theR2, theL2, theRL, theLtransL, - theRR, theLtransR, theRI, theLtransI, - aSeq, gp_Trsf())) { - return NULL; - } - } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - SetErrorCode(aFail->GetMessageString()); - return NULL; - } - - //Make a Python command - TCollection_AsciiString anEntry, aListRes("["); - // Iterate over the sequence aSeq - Standard_Integer aNbGroups = aSeq->Length(); - Standard_Integer i = 1; - for (; i <= aNbGroups; i++) { - Handle(Standard_Transient) anItem = aSeq->Value(i); - if (anItem.IsNull()) continue; - Handle(GEOM_Object) aGroup = Handle(GEOM_Object)::DownCast(anItem); - if (aGroup.IsNull()) continue; - //Make a Python command - TDF_Tool::Entry(aGroup->GetEntry(), anEntry); - aListRes += anEntry + ", "; - } - aListRes.Trunc(aListRes.Length() - 2); - - GEOM::TPythonDump pd (aFunction); - - pd << aListRes.ToCString() << "] = geompy.MakePipeTShapeChamfer(" - << theR1 << ", " << theW1 << ", " << theL1 << ", " - << theR2 << ", " << theW2 << ", " << theL2 << ", " - << theH << ", " << theW << ", " << theHexMesh; - - // thickness reduction - if (isTRL) - pd << ", theRL=" << theRL << ", theWL=" << theWL - << ", theLtransL=" << theLtransL << ", theLthinL=" << theLthinL; - if (isTRR) - pd << ", theRR=" << theRR << ", theWR=" << theWR - << ", theLtransR=" << theLtransR << ", theLthinR=" << theLthinR; - if (isTRI) - pd << ", theRI=" << theRI << ", theWI=" << theWI - << ", theLtransI=" << theLtransI << ", theLthinI=" << theLthinI; - - pd << ")"; - - SetErrorCode(OK); - - return aSeq; -} - -//============================================================================= -/*! - * MakePipeTShapeChamferWithPosition - * Create a T-shape object with specified caracteristics for the main and - * the incident pipes (radius, width, half-length). A chamfer is created - * on the junction of the pipes. - * The extremities of the main pipe are located on junctions points P1 and P2. - * The extremity of the incident pipe is located on junction point P3. - * \param theR1 Internal radius of main pipe - * \param theW1 Width of main pipe - * \param theL1 Half-length of main pipe - * \param theR2 Internal radius of incident pipe (R2 < R1) - * \param theW2 Width of incident pipe (R2+W2 < R1+W1) - * \param theL2 Half-length of incident pipe - * \param theH Height of chamfer. - * \param theW Width of chamfer. - * \param theHexMesh Boolean indicating if shape is prepared for hex mesh - * \param theP1 1st junction point of main pipe - * \param theP2 2nd junction point of main pipe - * \param theP3 Junction point of incident pipe - * \return List of GEOM_Objects, containing the created shape and propagation groups. - */ -//============================================================================= -Handle(TColStd_HSequenceOfTransient) -GEOMImpl_IAdvancedOperations::MakePipeTShapeChamferWithPosition - (double theR1, double theW1, double theL1, - double theR2, double theW2, double theL2, - double theRL, double theWL, double theLtransL, double theLthinL, - double theRR, double theWR, double theLtransR, double theLthinR, - double theRI, double theWI, double theLtransI, double theLthinI, - double theH, double theW, - bool theHexMesh, - Handle(GEOM_Object) theP1, - Handle(GEOM_Object) theP2, - Handle(GEOM_Object) theP3) -{ - SetErrorCode(KO); - //Add a new object - Handle(GEOM_Object) aShape = GetEngine()->AddObject(GetDocID(), GEOM_TSHAPE); - //Add a new shape function with parameters - Handle(GEOM_Function) aFunction = aShape->AddFunction(GEOMImpl_PipeTShapeDriver::GetID(), TSHAPE_CHAMFER); - if (aFunction.IsNull()) return NULL; - - //Check if the function is set correctly - if (aFunction->GetDriverGUID() != GEOMImpl_PipeTShapeDriver::GetID()) return NULL; - - // Check new position - if (!CheckCompatiblePosition(theL1, theL2, theP1, theP2, theP3, 0.01)) { - return NULL; - } - - GEOMImpl_IPipeTShape aData(aFunction); - - aData.SetR1(theR1); - aData.SetW1(theW1); - aData.SetL1(theL1); - aData.SetR2(theR2); - aData.SetW2(theW2); - aData.SetL2(theL2); - aData.SetH(theH); - aData.SetW(theW); - aData.SetHexMesh(theHexMesh); - - bool isTRL = (theRL + theWL + theLtransL + theLthinL) > Precision::Confusion(); - bool isTRR = (theRR + theWR + theLtransR + theLthinR) > Precision::Confusion(); - bool isTRI = (theRI + theWI + theLtransI + theLthinI) > Precision::Confusion(); - - //Compute the resulting value - try { -#if OCC_VERSION_LARGE > 0x06010000 - OCC_CATCH_SIGNALS; -#endif - if (!GetSolver()->ComputeFunction(aFunction)) { - SetErrorCode("TShape driver failed"); - return NULL; - } - } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - SetErrorCode(aFail->GetMessageString()); - return NULL; - } - - // BEGIN of chamfer - TopoDS_Shape aShapeShape = aShape->GetValue(); - TopTools_IndexedMapOfShape anEdgesIndices; - TopExp::MapShapes(aShapeShape, anEdgesIndices); - // Common edges on external cylinders - Handle(GEOM_Object) box_e; - if (theHexMesh) { - box_e = my3DPrimOperations->MakeBoxDXDYDZ(theR2+theW2, theR2+theW2, theR1+theW1); - } - else { - box_e = my3DPrimOperations->MakeBoxDXDYDZ(2*(theR2+theW2), 2*(theR2+theW2), theR1+theW1); - } - box_e->GetLastFunction()->SetDescription(""); - box_e = myTransformOperations->TranslateDXDYDZ(box_e, -(theR2+theW2), -(theR2+theW2), 0); - box_e->GetLastFunction()->SetDescription(""); - - Handle(TColStd_HSequenceOfInteger) edges_e = - myShapesOperations->GetShapesOnBoxIDs(box_e, aShape, TopAbs_EDGE, GEOMAlgo_ST_IN); - box_e->GetLastFunction()->SetDescription(""); - - if (edges_e.IsNull() || edges_e->Length() == 0) { - SetErrorCode("External edges not found"); - return NULL; - } - int nbEdgesInChamfer = 0; - std::list theEdges; - for (int i=1; i<=edges_e->Length();i++) { - int edgeID = edges_e->Value(i); - TopoDS_Shape theEdge = anEdgesIndices.FindKey(edgeID); - TopExp_Explorer Ex(theEdge,TopAbs_VERTEX); - while (Ex.More()) { - gp_Pnt aPt = BRep_Tool::Pnt(TopoDS::Vertex(Ex.Current())); - if (Abs(aPt.Z() - (theR1+theW1)) <= Precision::Confusion()) { - nbEdgesInChamfer ++; - theEdges.push_back(edgeID); - } - Ex.Next(); - } - if (theHexMesh && nbEdgesInChamfer == 1) - break; - } - Handle(GEOM_Object) aChamfer; - try { - aChamfer = myLocalOperations->MakeChamferEdges(aShape, theW, theH, theEdges); - } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - SetErrorCode(aFail->GetMessageString()); - return NULL; - } - if (aChamfer.IsNull()) { - SetErrorCode("Chamfer can not be computed on the given shape with the given parameters"); - return NULL; - } - aChamfer->GetLastFunction()->SetDescription(""); - - TopoDS_Shape aChamferShape = aChamfer->GetValue(); - aFunction->SetValue(aChamferShape); - // END of chamfer - - if (theHexMesh) { - if (!MakePipeTShapePartition(aShape, theR1, theW1, theL1, theR2, theW2, theL2, theH, theW, 0, false)) - return NULL; - if (!MakePipeTShapeMirrorAndGlue(aShape, theR1, theW1, theL1, theR2, theW2, theL2)) - return NULL; - } - - // Add thickness reduction elements - // at the three extremities: Left, Right and Incident - try { -#if OCC_VERSION_LARGE > 0x06010000 - OCC_CATCH_SIGNALS; -#endif - if (isTRL || isTRR || isTRI) { - TopoDS_Shape aResShape = - MakePipeTShapeThicknessReduction(aShape->GetValue(), theR1, theW1, theL1, theR2, theW2, theL2, - theRL, theWL, theLtransL, theLthinL, - theRR, theWR, theLtransR, theLthinR, - theRI, theWI, theLtransI, theLthinI, - !theHexMesh); - aFunction->SetValue(aResShape); - } - } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - SetErrorCode(aFail->GetMessageString()); - return NULL; - } - - // Set Position - gp_Trsf aTrsf = GetPositionTrsf(theL1, theL2, theP1, theP2, theP3); - BRepBuilderAPI_Transform aTransformation (aShape->GetValue(), aTrsf, Standard_False); - TopoDS_Shape aTrsf_Shape = aTransformation.Shape(); - aFunction->SetValue(aTrsf_Shape); - - Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient; - aSeq->Append(aShape); - - try { - if (theHexMesh) { - // Get the groups - if (!MakeGroups(aShape, TSHAPE_CHAMFER, theR1, theW1, theL1, theR2, theW2, theL2, - theH, theW, 0., aSeq, aTrsf)) - return NULL; - } - - // Get internal group. - if (!MakeInternalGroup(aShape, theR1, theL1, theR2, theL2, theRL, theLtransL, - theRR, theLtransR, theRI, theLtransI, - aSeq, aTrsf)) { - return NULL; - } - } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - SetErrorCode(aFail->GetMessageString()); - return NULL; - } - - //Make a Python command - TCollection_AsciiString anEntry, aListRes("["); - // Iterate over the sequence aSeq - Standard_Integer aNbGroups = aSeq->Length(); - Standard_Integer i = 1; - for (; i <= aNbGroups; i++) { - Handle(Standard_Transient) anItem = aSeq->Value(i); - if (anItem.IsNull()) continue; - Handle(GEOM_Object) aGroup = Handle(GEOM_Object)::DownCast(anItem); - if (aGroup.IsNull()) continue; - //Make a Python command - TDF_Tool::Entry(aGroup->GetEntry(), anEntry); - aListRes += anEntry + ", "; - } - aListRes.Trunc(aListRes.Length() - 2); - - GEOM::TPythonDump pd (aFunction); - - pd << aListRes.ToCString() << "] = geompy.MakePipeTShapeChamfer(" - << theR1 << ", " << theW1 << ", " << theL1 << ", " - << theR2 << ", " << theW2 << ", " << theL2 << ", " - << theH << ", " << theW << ", " << theHexMesh << ", " - << theP1 << ", " << theP2 << ", " << theP3; - - // thickness reduction - if (isTRL) - pd << ", theRL=" << theRL << ", theWL=" << theWL - << ", theLtransL=" << theLtransL << ", theLthinL=" << theLthinL; - if (isTRR) - pd << ", theRR=" << theRR << ", theWR=" << theWR - << ", theLtransR=" << theLtransR << ", theLthinR=" << theLthinR; - if (isTRI) - pd << ", theRI=" << theRI << ", theWI=" << theWI - << ", theLtransI=" << theLtransI << ", theLthinI=" << theLthinI; - - pd << ")"; - - SetErrorCode(OK); - - return aSeq; -} - -//============================================================================= -/*! - * MakePipeTShapeFillet - * Create a T-shape object with specified caracteristics for the main and - * the incident pipes (radius, width, half-length). A fillet is created - * on the junction of the pipes. - * Center of the shape is (0,0,0). The main plane of the T-shape is XOY. - * \param theR1 Internal radius of main pipe - * \param theW1 Width of main pipe - * \param theL1 Half-length of main pipe - * \param theR2 Internal radius of incident pipe (R2 < R1) - * \param theW2 Width of incident pipe (R2+W2 < R1+W1) - * \param theL2 Half-length of incident pipe - * \param theRF Radius of curvature of fillet. - * \param theHexMesh Boolean indicating if shape is prepared for hex mesh - * \return List of GEOM_Objects, containing the created shape and propagation groups. - */ -//============================================================================= -Handle(TColStd_HSequenceOfTransient) -GEOMImpl_IAdvancedOperations::MakePipeTShapeFillet - (double theR1, double theW1, double theL1, - double theR2, double theW2, double theL2, - double theRL, double theWL, double theLtransL, double theLthinL, - double theRR, double theWR, double theLtransR, double theLthinR, - double theRI, double theWI, double theLtransI, double theLthinI, - double theRF, bool theHexMesh) -{ - SetErrorCode(KO); - //Add a new object - Handle(GEOM_Object) aShape = GetEngine()->AddObject(GetDocID(), GEOM_TSHAPE); - //Add a new shape function with parameters - Handle(GEOM_Function) aFunction = aShape->AddFunction(GEOMImpl_PipeTShapeDriver::GetID(), TSHAPE_FILLET); - if (aFunction.IsNull()) return NULL; - - //Check if the function is set correctly - if (aFunction->GetDriverGUID() != GEOMImpl_PipeTShapeDriver::GetID()) return NULL; - - GEOMImpl_IPipeTShape aData(aFunction); - - aData.SetR1(theR1); - aData.SetW1(theW1); - aData.SetL1(theL1); - aData.SetR2(theR2); - aData.SetW2(theW2); - aData.SetL2(theL2); - aData.SetRF(theRF); - aData.SetHexMesh(theHexMesh); - - bool isTRL = (theRL + theWL + theLtransL + theLthinL) > Precision::Confusion(); - bool isTRR = (theRR + theWR + theLtransR + theLthinR) > Precision::Confusion(); - bool isTRI = (theRI + theWI + theLtransI + theLthinI) > Precision::Confusion(); - - //Compute the resulting value - try { -#if OCC_VERSION_LARGE > 0x06010000 - OCC_CATCH_SIGNALS; -#endif - if (!GetSolver()->ComputeFunction(aFunction)) { - SetErrorCode("TShape driver failed"); - return NULL; - } - } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - SetErrorCode(aFail->GetMessageString()); - return NULL; - } - - // BEGIN of fillet - TopoDS_Shape aShapeShape = aShape->GetValue(); - TopTools_IndexedMapOfShape anEdgesIndices; - TopExp::MapShapes(aShapeShape, anEdgesIndices); - // Common edges on external cylinders - Handle(GEOM_Object) box_e; - if (theHexMesh) { - box_e = my3DPrimOperations->MakeBoxDXDYDZ(theR2+theW2, theR2+theW2, theR1+theW1); - } - else { - box_e = my3DPrimOperations->MakeBoxDXDYDZ(2*(theR2+theW2), 2*(theR2+theW2), theR1+theW1); - } - box_e->GetLastFunction()->SetDescription(""); - box_e = myTransformOperations->TranslateDXDYDZ(box_e, -(theR2+theW2), -(theR2+theW2), 0); - box_e->GetLastFunction()->SetDescription(""); - - Handle(TColStd_HSequenceOfInteger) edges_e = - myShapesOperations->GetShapesOnBoxIDs(box_e, aShape, TopAbs_EDGE, GEOMAlgo_ST_IN); - box_e->GetLastFunction()->SetDescription(""); - - if (edges_e.IsNull() || edges_e->Length() == 0) { - SetErrorCode("External edges not found"); - return NULL; - } - int nbEdgesInFillet = 0; - std::list theEdges; - for (int i=1; i<=edges_e->Length();i++) { - int edgeID = edges_e->Value(i); - TopoDS_Shape theEdge = anEdgesIndices.FindKey(edgeID); - TopExp_Explorer Ex(theEdge,TopAbs_VERTEX); - while (Ex.More()) { - gp_Pnt aPt = BRep_Tool::Pnt(TopoDS::Vertex(Ex.Current())); - if (Abs(aPt.Z() - (theR1+theW1)) <= Precision::Confusion()) { - nbEdgesInFillet ++; - theEdges.push_back(edgeID); - } - Ex.Next(); - } - if (theHexMesh && nbEdgesInFillet == 1) - break; - } - - Handle(GEOM_Object) aFillet; - try { - aFillet = myLocalOperations->MakeFilletEdges(aShape, theRF, theEdges); - } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - SetErrorCode(aFail->GetMessageString()); - return NULL; - } - if (aFillet.IsNull()) { - //SetErrorCode("Fillet can not be computed on the given shape with the given parameters"); - SetErrorCode(myLocalOperations->GetErrorCode()); - return NULL; - } - aFillet->GetLastFunction()->SetDescription(""); - - TopoDS_Shape aFilletShape = aFillet->GetValue(); - aFunction->SetValue(aFilletShape); - // END of fillet - -// VSR: debug issues 0021568 and 0021550 (15/05/2012) - BEGIN (1) -// the following block, when enabled, leads to partitioning problems -#if 0 -// VSR: debug issues 0021568 and 0021550 (15/05/2012) - END (1) - // BEGIN: Limit tolerances (debug) - Handle(GEOM_Object) aCorr1 = myHealingOperations->LimitTolerance(aShape, 1e-07); - TopoDS_Shape aCorr1Shape = aCorr1->GetValue(); - aShape->GetLastFunction()->SetValue(aCorr1Shape); - aCorr1->GetLastFunction()->SetDescription(""); - // END: Limit tolerances (debug) -// VSR: debug issues 0021568 and 0021550 (15/05/2012) - BEGIN (2) -#endif -// VSR: debug issues 0021568 and 0021550 (15/05/2012) - END (2) - - if (theHexMesh) { - if (!MakePipeTShapePartition(aShape, theR1, theW1, theL1, theR2, theW2, theL2, 0, 0, theRF, false)) - return NULL; - if (!MakePipeTShapeMirrorAndGlue(aShape, theR1, theW1, theL1, theR2, theW2, theL2)) - return NULL; - } - - // Add thickness reduction elements - // at the three extremities: Left, Right and Incident - try { -#if OCC_VERSION_LARGE > 0x06010000 - OCC_CATCH_SIGNALS; -#endif - if (isTRL || isTRR || isTRI) { - TopoDS_Shape aResShape = - MakePipeTShapeThicknessReduction(aShape->GetValue(), theR1, theW1, theL1, theR2, theW2, theL2, - theRL, theWL, theLtransL, theLthinL, - theRR, theWR, theLtransR, theLthinR, - theRI, theWI, theLtransI, theLthinI, - !theHexMesh); - aFunction->SetValue(aResShape); - } - } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - SetErrorCode(aFail->GetMessageString()); - return NULL; - } - - Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient; - aSeq->Append(aShape); - - try { - if (theHexMesh) { - // Get the groups - if (!MakeGroups(aShape, TSHAPE_FILLET, theR1, theW1, theL1, theR2, theW2, theL2, - 0., 0., theRF, aSeq, gp_Trsf())) - return NULL; - } - - // Get internal group. - if (!MakeInternalGroup(aShape, theR1, theL1, theR2, theL2, theRL, theLtransL, - theRR, theLtransR, theRI, theLtransI, - aSeq, gp_Trsf())) { - return NULL; - } - } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - SetErrorCode(aFail->GetMessageString()); - return NULL; - } - - //Make a Python command - TCollection_AsciiString anEntry, aListRes("["); - // Iterate over the sequence aSeq - Standard_Integer aNbGroups = aSeq->Length(); - Standard_Integer i = 1; - for (; i <= aNbGroups; i++) { - Handle(Standard_Transient) anItem = aSeq->Value(i); - if (anItem.IsNull()) continue; - Handle(GEOM_Object) aGroup = Handle(GEOM_Object)::DownCast(anItem); - if (aGroup.IsNull()) continue; - //Make a Python command - TDF_Tool::Entry(aGroup->GetEntry(), anEntry); - aListRes += anEntry + ", "; - } - aListRes.Trunc(aListRes.Length() - 2); - - GEOM::TPythonDump pd (aFunction); - - pd << aListRes.ToCString() << "] = geompy.MakePipeTShapeFillet(" - << theR1 << ", " << theW1 << ", " << theL1 << ", " - << theR2 << ", " << theW2 << ", " << theL2 << ", " - << theRF << ", " << theHexMesh; - - // thickness reduction - if (isTRL) - pd << ", theRL=" << theRL << ", theWL=" << theWL - << ", theLtransL=" << theLtransL << ", theLthinL=" << theLthinL; - if (isTRR) - pd << ", theRR=" << theRR << ", theWR=" << theWR - << ", theLtransR=" << theLtransR << ", theLthinR=" << theLthinR; - if (isTRI) - pd << ", theRI=" << theRI << ", theWI=" << theWI - << ", theLtransI=" << theLtransI << ", theLthinI=" << theLthinI; - - pd << ")"; - - SetErrorCode(OK); - - return aSeq; -} - -//============================================================================= -/*! - * MakePipeTShapeFilletWithPosition - * \brief Create a T-shape object with specified caracteristics for the main and - * the incident pipes (radius, width, half-length). A fillet is created - * on the junction of the pipes. - * The extremities of the main pipe are located on junctions points P1 and P2. - * The extremity of the incident pipe is located on junction point P3. - * \param theR1 Internal radius of main pipe - * \param theW1 Width of main pipe - * \param theL1 Half-length of main pipe - * \param theR2 Internal radius of incident pipe (R2 < R1) - * \param theW2 Width of incident pipe (R2+W2 < R1+W1) - * \param theL2 Half-length of incident pipe - * \param theRF Radius of curvature of fillet - * \param theHexMesh Boolean indicating if shape is prepared for hex mesh - * \param theP1 1st junction point of main pipe - * \param theP2 2nd junction point of main pipe - * \param theP3 Junction point of incident pipe - * \return List of GEOM_Objects, containing the created shape and propagation groups. - */ -//============================================================================= -Handle(TColStd_HSequenceOfTransient) -GEOMImpl_IAdvancedOperations::MakePipeTShapeFilletWithPosition - (double theR1, double theW1, double theL1, - double theR2, double theW2, double theL2, - double theRL, double theWL, double theLtransL, double theLthinL, - double theRR, double theWR, double theLtransR, double theLthinR, - double theRI, double theWI, double theLtransI, double theLthinI, - double theRF, bool theHexMesh, - Handle(GEOM_Object) theP1, - Handle(GEOM_Object) theP2, - Handle(GEOM_Object) theP3) -{ - SetErrorCode(KO); - //Add a new object - Handle(GEOM_Object) aShape = GetEngine()->AddObject(GetDocID(), GEOM_TSHAPE); - //Add a new shape function with parameters - Handle(GEOM_Function) aFunction = aShape->AddFunction(GEOMImpl_PipeTShapeDriver::GetID(), TSHAPE_FILLET); - if (aFunction.IsNull()) return NULL; - - //Check if the function is set correctly - if (aFunction->GetDriverGUID() != GEOMImpl_PipeTShapeDriver::GetID()) return NULL; - - // Check new position - if (!CheckCompatiblePosition(theL1, theL2, theP1, theP2, theP3, 0.01)) { - return NULL; - } - - GEOMImpl_IPipeTShape aData(aFunction); - - aData.SetR1(theR1); - aData.SetW1(theW1); - aData.SetL1(theL1); - aData.SetR2(theR2); - aData.SetW2(theW2); - aData.SetL2(theL2); - aData.SetRF(theRF); - aData.SetHexMesh(theHexMesh); - - bool isTRL = (theRL + theWL + theLtransL + theLthinL) > Precision::Confusion(); - bool isTRR = (theRR + theWR + theLtransR + theLthinR) > Precision::Confusion(); - bool isTRI = (theRI + theWI + theLtransI + theLthinI) > Precision::Confusion(); - - //Compute the resulting value - try { -#if OCC_VERSION_LARGE > 0x06010000 - OCC_CATCH_SIGNALS; -#endif - if (!GetSolver()->ComputeFunction(aFunction)) { - SetErrorCode("TShape driver failed"); - return NULL; - } - } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - SetErrorCode(aFail->GetMessageString()); - return NULL; - } - - // BEGIN of fillet - TopoDS_Shape aShapeShape = aShape->GetValue(); - TopTools_IndexedMapOfShape anEdgesIndices; - TopExp::MapShapes(aShapeShape, anEdgesIndices); - // Common edges on external cylinders - Handle(GEOM_Object) box_e; - if (theHexMesh) { - box_e = my3DPrimOperations->MakeBoxDXDYDZ(theR2+theW2, theR2+theW2, theR1+theW1); - } - else { - box_e = my3DPrimOperations->MakeBoxDXDYDZ(2*(theR2+theW2), 2*(theR2+theW2), theR1+theW1); - } - box_e->GetLastFunction()->SetDescription(""); - box_e = myTransformOperations->TranslateDXDYDZ(box_e, -(theR2+theW2), -(theR2+theW2), 0); - box_e->GetLastFunction()->SetDescription(""); - - Handle(TColStd_HSequenceOfInteger) edges_e = - myShapesOperations->GetShapesOnBoxIDs(box_e, aShape, TopAbs_EDGE, GEOMAlgo_ST_IN); - box_e->GetLastFunction()->SetDescription(""); - - if (edges_e.IsNull() || edges_e->Length() == 0) { - SetErrorCode("External edges not found"); - return NULL; - } - int nbEdgesInFillet = 0; - std::list theEdges; - for (int i=1; i<=edges_e->Length();i++) { - int edgeID = edges_e->Value(i); - TopoDS_Shape theEdge = anEdgesIndices.FindKey(edgeID); - TopExp_Explorer Ex(theEdge,TopAbs_VERTEX); - while (Ex.More()) { - gp_Pnt aPt = BRep_Tool::Pnt(TopoDS::Vertex(Ex.Current())); - if (Abs(aPt.Z() - (theR1+theW1)) <= Precision::Confusion()) { - nbEdgesInFillet ++; - theEdges.push_back(edgeID); - } - Ex.Next(); - } - if (theHexMesh && nbEdgesInFillet == 1) - break; - } - - Handle(GEOM_Object) aFillet; - try { - aFillet = myLocalOperations->MakeFilletEdges(aShape, theRF, theEdges); - } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - SetErrorCode(aFail->GetMessageString()); - return NULL; - } - if (aFillet.IsNull()) { - SetErrorCode("Fillet can not be computed on the given shape with the given parameters"); - return NULL; - } - aFillet->GetLastFunction()->SetDescription(""); - - TopoDS_Shape aFilletShape = aFillet->GetValue(); - aFunction->SetValue(aFilletShape); - // END of fillet - -// VSR: debug issues 0021568 and 0021550 (15/05/2012) - BEGIN (3) -// the following block, when enabled, leads to partitioning problems -#if 0 -// VSR: debug issues 0021568 and 0021550 (15/05/2012) - END (3) - // BEGIN: Limit tolerances (debug) - Handle(GEOM_Object) aCorr1 = myHealingOperations->LimitTolerance(aShape, 1e-07); - TopoDS_Shape aCorr1Shape = aCorr1->GetValue(); - aShape->GetLastFunction()->SetValue(aCorr1Shape); - aCorr1->GetLastFunction()->SetDescription(""); - // END: Limit tolerances (debug) -// VSR: debug issues 0021568 and 0021550 (15/05/2012) - BEGIN (4) -#endif -// VSR: debug issues 0021568 and 0021550 (15/05/2012) - END (4) - - if (theHexMesh) { - if (!MakePipeTShapePartition(aShape, theR1, theW1, theL1, theR2, theW2, theL2, 0, 0, theRF, false)) - return NULL; - if (!MakePipeTShapeMirrorAndGlue(aShape, theR1, theW1, theL1, theR2, theW2, theL2)) - return NULL; - } - - // Add thickness reduction elements - // at the three extremities: Left, Right and Incident - try { -#if OCC_VERSION_LARGE > 0x06010000 - OCC_CATCH_SIGNALS; -#endif - if (isTRL || isTRR || isTRI) { - TopoDS_Shape aResShape = - MakePipeTShapeThicknessReduction(aShape->GetValue(), theR1, theW1, theL1, theR2, theW2, theL2, - theRL, theWL, theLtransL, theLthinL, - theRR, theWR, theLtransR, theLthinR, - theRI, theWI, theLtransI, theLthinI, - !theHexMesh); - aFunction->SetValue(aResShape); - } - } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - SetErrorCode(aFail->GetMessageString()); - return NULL; - } - - // Set Position - gp_Trsf aTrsf = GetPositionTrsf(theL1, theL2, theP1, theP2, theP3); - BRepBuilderAPI_Transform aTransformation (aShape->GetValue(), aTrsf, Standard_False); - TopoDS_Shape aTrsf_Shape = aTransformation.Shape(); - aFunction->SetValue(aTrsf_Shape); - - Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient; - aSeq->Append(aShape); - - try { - if (theHexMesh) { - // Get the groups - if (!MakeGroups(aShape, TSHAPE_FILLET, theR1, theW1, theL1, theR2, theW2, theL2, - 0., 0., theRF, aSeq, aTrsf)) - return NULL; - } - - // Get internal group. - if (!MakeInternalGroup(aShape, theR1, theL1, theR2, theL2, theRL, theLtransL, - theRR, theLtransR, theRI, theLtransI, - aSeq, aTrsf)) { - return NULL; - } - } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - SetErrorCode(aFail->GetMessageString()); - return NULL; - } - - //Make a Python command - TCollection_AsciiString anEntry, aListRes("["); - // Iterate over the sequence aSeq - Standard_Integer aNbGroups = aSeq->Length(); - Standard_Integer i = 1; - for (; i <= aNbGroups; i++) { - Handle(Standard_Transient) anItem = aSeq->Value(i); - if (anItem.IsNull()) continue; - Handle(GEOM_Object) aGroup = Handle(GEOM_Object)::DownCast(anItem); - if (aGroup.IsNull()) continue; - //Make a Python command - TDF_Tool::Entry(aGroup->GetEntry(), anEntry); - aListRes += anEntry + ", "; - } - aListRes.Trunc(aListRes.Length() - 2); - - GEOM::TPythonDump pd (aFunction); - - pd << aListRes.ToCString() << "] = geompy.MakePipeTShapeFillet(" - << theR1 << ", " << theW1 << ", " << theL1 << ", " - << theR2 << ", " << theW2 << ", " << theL2 << ", " - << theRF << ", " << theHexMesh << ", " - << theP1 << ", " << theP2 << ", " << theP3; - - // thickness reduction - if (isTRL) - pd << ", theRL=" << theRL << ", theWL=" << theWL - << ", theLtransL=" << theLtransL << ", theLthinL=" << theLthinL; - if (isTRR) - pd << ", theRR=" << theRR << ", theWR=" << theWR - << ", theLtransR=" << theLtransR << ", theLthinR=" << theLthinR; - if (isTRI) - pd << ", theRI=" << theRI << ", theWI=" << theWI - << ", theLtransI=" << theLtransI << ", theLthinI=" << theLthinI; - - pd << ")"; - - SetErrorCode(OK); - - return aSeq; -} - -//============================================================================= -/*! - * This function allows to create a disk already divided into blocks. It can be - * used to create divided pipes for later meshing in hexaedra. - * \param theR Radius of the disk - * \param theRatio Relative size of the central square diagonal against the disk diameter - * \param theOrientation Plane on which the disk will be built - * \param thePattern The division pattern of the disk (hexagon or square in the center) - * \return New GEOM_Object, containing the created shape. - */ -//============================================================================= -Handle(GEOM_Object) GEOMImpl_IAdvancedOperations::MakeDividedDisk (double theR, double theRatio, - int theOrientation, int thePattern) -{ - SetErrorCode(KO); - - if (theOrientation != 1 && - theOrientation != 2 && - theOrientation != 3) - { - SetErrorCode("theOrientation must be 1(=OXY), 2(=OYZ) or 3(=OZX)"); - return NULL; - } - //Add a new object - Handle(GEOM_Object) aShape = GetEngine()->AddObject(GetDocID(), GEOM_DIVIDEDDISK); - - //Add a new shape function with parameters - Handle(GEOM_Function) aFunction = aShape->AddFunction(GEOMImpl_DividedDiskDriver::GetID(), DIVIDEDDISK_R_RATIO); - if (aFunction.IsNull()) return NULL; - - //Check if the function is set correctly - if (aFunction->GetDriverGUID() != GEOMImpl_DividedDiskDriver::GetID()) return NULL; - - GEOMImpl_IDividedDisk aData (aFunction); - - aData.SetR(theR); - aData.SetRatio(theRatio); - aData.SetOrientation(theOrientation); - aData.SetType(thePattern); - - //Compute the resulting value - try { -#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 - OCC_CATCH_SIGNALS; -#endif - if (!GetSolver()->ComputeFunction(aFunction)) { - SetErrorCode("DividedDisk driver failed"); - return NULL; - } - } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - SetErrorCode(aFail->GetMessageString()); - return NULL; - } - - std::string aPatternStr; - - switch(thePattern) - { - case 0: - aPatternStr = "GEOM.SQUARE"; - break; - case 1: - aPatternStr = "GEOM.HEXAGON"; - break; - } - - //Make a Python command - GEOM::TPythonDump(aFunction) << aShape << " = geompy.MakeDividedDisk(" << theR << ", " << theOrientation << ", " << aPatternStr.c_str() << ")"; - - SetErrorCode(OK); - - return aShape; -} - -//============================================================================= -/*! - * This function allows to create a disk already divided into blocks. It can be - * used to create divided pipes for later meshing in hexaedra. - * \param theR Radius of the disk - * \param theRatio Relative size of the central square diagonal against the disk diameter - * \return New GEOM_Object, containing the created shape. - */ -//============================================================================= -Handle(GEOM_Object) GEOMImpl_IAdvancedOperations::MakeDividedDiskPntVecR (Handle(GEOM_Object) thePnt, - Handle(GEOM_Object) theVec, - double theR, - double theRatio, - int thePattern) -{ - SetErrorCode(KO); - - //Add a new object - Handle(GEOM_Object) aShape = GetEngine()->AddObject(GetDocID(), GEOM_DIVIDEDDISK); - - //Add a new shape function with parameters - Handle(GEOM_Function) aFunction = aShape->AddFunction(GEOMImpl_DividedDiskDriver::GetID(), DIVIDEDDISK_R_VECTOR_PNT); - if (aFunction.IsNull()) return NULL; - - //Check if the function is set correctly - if (aFunction->GetDriverGUID() != GEOMImpl_DividedDiskDriver::GetID()) return NULL; - - GEOMImpl_IDividedDisk aData (aFunction); - - Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction(); - Handle(GEOM_Function) aRefVec = theVec->GetLastFunction(); - - if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL; - - aData.SetCenter(aRefPnt); - aData.SetVector(aRefVec); - - aData.SetR(theR); - aData.SetRatio(theRatio); - aData.SetType(thePattern); - - //Compute the resulting value - try { -#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 - OCC_CATCH_SIGNALS; -#endif - if (!GetSolver()->ComputeFunction(aFunction)) { - SetErrorCode("DividedDisk driver failed"); - return NULL; - } - } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - SetErrorCode(aFail->GetMessageString()); - return NULL; - } - - std::string aPatternStr; - - switch(thePattern) - { - case 0: - aPatternStr = "GEOM.SQUARE"; - break; - case 1: - aPatternStr = "GEOM.HEXAGON"; - break; - } - - - //Make a Python command - GEOM::TPythonDump(aFunction) << aShape << " = geompy.MakeDividedDiskPntVecR(" << thePnt << ", " << theVec << ", " << theR << ", " << aPatternStr.c_str() << ")"; - - SetErrorCode(OK); - - return aShape; -} - -//============================================================================= -/*! - * Builds a cylinder prepared for hexa meshes - * \param theR Radius of the cylinder - * \param theH Height of the cylinder - * \return New GEOM_Object, containing the created shape. - */ -//============================================================================= -Handle(GEOM_Object) GEOMImpl_IAdvancedOperations::MakeDividedCylinder (double theR, - double theH, - int thePattern) -{ - SetErrorCode(KO); - - //Add a new object - Handle(GEOM_Object) aShape = GetEngine()->AddObject(GetDocID(), GEOM_DIVIDEDCYLINDER); - - Handle(GEOM_Object) aBaseShape = MakeDividedDisk(theR, 67.0, 1, thePattern); - aBaseShape->GetLastFunction()->SetDescription(""); // Erase dump of MakeDividedDisk - - aShape = my3DPrimOperations->MakePrismDXDYDZ(aBaseShape,0.0,0.0,theH, -1.0); - - Handle(GEOM_Function) aFunction = aShape->GetLastFunction(); - aFunction->SetDescription(""); // Erase dump of MakePrismDXDYDZ - aShape->SetType(GEOM_DIVIDEDCYLINDER); - - std::string aPatternStr; - - switch(thePattern) - { - case 0: - aPatternStr = "GEOM.SQUARE"; - break; - case 1: - aPatternStr = "GEOM.HEXAGON"; - break; - } - - //Make a Python command - GEOM::TPythonDump(aFunction) << aShape << " = geompy.MakeDividedCylinder(" << theR << ", " << theH << ", " << aPatternStr.c_str() << ")"; - - SetErrorCode(OK); - - return aShape; -} -//============================================================================= -/*! - * Create a smoothing surface from a set of points - * \param thelPoints list of points - * \return New GEOM_Object, containing the created shape. - */ -//============================================================================= -Handle(GEOM_Object) GEOMImpl_IAdvancedOperations::MakeSmoothingSurface (std::list thelPoints) -{ - SetErrorCode(KO); - - //Add a new object - Handle(GEOM_Object) aShape = GetEngine()->AddObject(GetDocID(), GEOM_SMOOTHINGSURFACE); - - //Add a new shape function with parameters - Handle(GEOM_Function) aFunction = aShape->AddFunction(GEOMImpl_SmoothingSurfaceDriver::GetID(), SMOOTHINGSURFACE_LPOINTS); - if (aFunction.IsNull()) return NULL; - - //Check if the function is set correctly - if (aFunction->GetDriverGUID() != GEOMImpl_SmoothingSurfaceDriver::GetID()) return NULL; - - GEOMImpl_ISmoothingSurface aData (aFunction); - - int aLen = thelPoints.size(); - aData.SetLength(aLen); - int ind = 1; - std::list::iterator it = thelPoints.begin(); - for (; it != thelPoints.end(); it++, ind++) { - Handle(GEOM_Function) aRefPnt = (*it)->GetLastFunction(); - if (aRefPnt.IsNull()) { - SetErrorCode("NULL point for bSplineFaceShape"); - return NULL; - } - aData.SetPoint(ind, aRefPnt); - } - - - //Compute the resulting value - try { -#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 - OCC_CATCH_SIGNALS; -#endif - if (!GetSolver()->ComputeFunction(aFunction)) { - SetErrorCode("SmoothingSurface driver failed"); - return NULL; - } - } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - SetErrorCode(aFail->GetMessageString()); - return NULL; - } - - //Make a Python command - GEOM::TPythonDump pd (aFunction); - pd << aShape << " = geompy.MakeSmoothingSurface(["; - it = thelPoints.begin(); - pd << (*it++); - while (it != thelPoints.end()) { - pd << ", " << (*it++); - } - pd << "])"; - - SetErrorCode(OK); - - return aShape; -} -/*@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@*/ diff --git a/src/GEOMImpl/GEOMImpl_IAdvancedOperations.hxx b/src/GEOMImpl/GEOMImpl_IAdvancedOperations.hxx deleted file mode 100644 index 2ee7edb2f..000000000 --- a/src/GEOMImpl/GEOMImpl_IAdvancedOperations.hxx +++ /dev/null @@ -1,242 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// File : GEOMImpl_IAdvancedOperations.hxx -// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) - -#ifndef _GEOMImpl_IAdvancedOperations_HXX_ -#define _GEOMImpl_IAdvancedOperations_HXX_ - -#include -#include "GEOM_IOperations.hxx" -#include "GEOM_Engine.hxx" -#include "GEOM_Object.hxx" - -#include -#include - -class GEOMImpl_IBasicOperations; -class GEOMImpl_IBooleanOperations; -class GEOMImpl_IShapesOperations; -class GEOMImpl_ITransformOperations; -class GEOMImpl_IBlocksOperations; -class GEOMImpl_I3DPrimOperations; -class GEOMImpl_ILocalOperations; -class GEOMImpl_IHealingOperations; -class GEOMImpl_IGroupOperations; -class Handle_Geom_Surface; -class TopTools_ListOfShape; - -class GEOMImpl_IAdvancedOperations: public GEOM_IOperations { -private: - bool MakePipeTShapePartition(Handle(GEOM_Object) theShape, - double theR1, double theW1, double theL1, - double theR2, double theW2, double theL2, - double theH = 0, double theW = 0, - double theRF = 0, bool isNormal = true); - - bool MakePipeTShapeMirrorAndGlue(Handle(GEOM_Object) theShape, - double theR1, double theW1, double theL1, - double theR2, double theW2, double theL2); - - bool MakePipeTShapeThicknessReduction (Handle(GEOM_Object) theShape, - double theR1, double theW1, double theL1, - double theR2, double theW2, double theL2, - double theRL, double theWL, double theLtransL, double theLthinL, - double theRR, double theWR, double theLtransR, double theLthinR, - double theRI, double theWI, double theLtransI, double theLthinI); - - bool MakeGroups(Handle(GEOM_Object) theShape, int shapType, - double theR1, double theW1, double theL1, - double theR2, double theW2, double theL2, - double theH, double theW, double theRF, - Handle(TColStd_HSequenceOfTransient) theSeq, - gp_Trsf aTrsf); - - bool GetFacesOnSurf(const TopoDS_Shape &theShape, - const Handle_Geom_Surface& theSurface, - const Standard_Real theTolerance, - TopTools_ListOfShape &theFaces); - - TopoDS_Shape MakeConicalFace(const gp_Ax2 &theAxis, - const double theRadius, - const double theRadiusThin, - const double theHeight, - const gp_Trsf &theTrsf); - - bool MakeInternalGroup(const Handle(GEOM_Object) &theShape, - const double theR1, const double theLen1, - const double theR2, const double theLen2, - const double theRL, const double theTransLenL, - const double theRR, const double theTransLenR, - const double theRI, const double theTransLenI, - const Handle(TColStd_HSequenceOfTransient) &theSeq, - const gp_Trsf &theTrsf); - - gp_Trsf GetPositionTrsf(double theL1, double theL2, - Handle(GEOM_Object) P1 = 0, - Handle(GEOM_Object) P2 = 0, - Handle(GEOM_Object) P3 = 0); - - bool CheckCompatiblePosition(double& theL1, double& theL2, - Handle(GEOM_Object) theP1, - Handle(GEOM_Object) theP2, - Handle(GEOM_Object) theP3, - double theTolerance); - -private: - GEOMImpl_IBasicOperations* myBasicOperations; - GEOMImpl_IBooleanOperations* myBooleanOperations; - GEOMImpl_IShapesOperations* myShapesOperations; - GEOMImpl_ITransformOperations* myTransformOperations; - GEOMImpl_IBlocksOperations* myBlocksOperations; - GEOMImpl_I3DPrimOperations* my3DPrimOperations; - GEOMImpl_ILocalOperations* myLocalOperations; - GEOMImpl_IHealingOperations* myHealingOperations; - GEOMImpl_IGroupOperations* myGroupOperations; - -public: - - /*! - * \brief Add three thickness reductions at the open ends of the pipe T-Shape - * - * \param theShape - the pipe T-Shape - * \param r1 - the internal radius of main pipe - * \param w1 - the thickness of main pipe - * \param l1 - the half-length of main pipe - * \param r2 - the internal radius of incident pipe - * \param w2 - the thickness of incident pipe - * \param l2 - the half-length of main pipe - * \param r*, w*, ltrans* and lthin* - internal radius, thickness, length of transition part - * and length of thin part of left(L), right(R) and - * incident(I) thickness reduction correspondingly - * \param fuseReductions - boolean flag (use true to generate single solid, - * false to obtain parts, useful for hexameshing) - * \retval TopoDS_Shape - Resulting shape - */ - Standard_EXPORT static TopoDS_Shape MakePipeTShapeThicknessReduction - (TopoDS_Shape theShape, - double r1, double w1, double l1, - double r2, double w2, double l2, - double rL, double wL, double ltransL, double lthinL, - double rR, double wR, double ltransR, double lthinR, - double rI, double wI, double ltransI, double lthinI, - bool fuseReductions); - - /*! - * \brief Create one thickness reduction element - * - * This method is called three times from MakePipeTShapeThicknessReduction - * to create three thickness reductions (one per each open end of a pipe T-Shape) - * - * \param theAxes - the position - * \param R - the internal radius of main pipe - * \param W - the thickness of main pipe - * \param Rthin - the internal radius of thin part - * \param Wthin - the thickness of thin part - * \param Ltrans - the length of transition part - * \param Lthin - the length of thin part - * \param fuse - boolean flag (use true to generate single solid, - * false to obtain parts, useful for hexameshing) - * \retval TopoDS_Shape - Resulting shape - */ - Standard_EXPORT static TopoDS_Shape MakeThicknessReduction (gp_Ax2 theAxes, - const double R, const double W, - const double Rthin, const double Wthin, - const double Ltrans, const double Lthin, - bool fuse); - -public: - Standard_EXPORT GEOMImpl_IAdvancedOperations(GEOM_Engine* theEngine, int theDocID); - Standard_EXPORT ~GEOMImpl_IAdvancedOperations(); - - Standard_EXPORT Handle(TColStd_HSequenceOfTransient) - MakePipeTShape(double theR1, double theW1, double theL1, - double theR2, double theW2, double theL2, - double theRL, double theWL, double theLtransL, double theLthinL, - double theRR, double theWR, double theLtransR, double theLthinR, - double theRI, double theWI, double theLtransI, double theLthinI, - bool theHexMesh = true); - - Standard_EXPORT Handle(TColStd_HSequenceOfTransient) - MakePipeTShapeWithPosition(double theR1, double theW1, double theL1, - double theR2, double theW2, double theL2, - double theRL, double theWL, double theLtransL, double theLthinL, - double theRR, double theWR, double theLtransR, double theLthinR, - double theRI, double theWI, double theLtransI, double theLthinI, - bool theHexMesh = true, - Handle(GEOM_Object) P1 = 0, - Handle(GEOM_Object) P2 = 0, - Handle(GEOM_Object) P3 = 0); - - Standard_EXPORT Handle(TColStd_HSequenceOfTransient) - MakePipeTShapeChamfer(double theR1, double theW1, double theL1, - double theR2, double theW2, double theL2, - double theRL, double theWL, double theLtransL, double theLthinL, - double theRR, double theWR, double theLtransR, double theLthinR, - double theRI, double theWI, double theLtransI, double theLthinI, - double theH, double theW, - bool theHexMesh = true); - - Standard_EXPORT Handle(TColStd_HSequenceOfTransient) - MakePipeTShapeChamferWithPosition(double theR1, double theW1, double theL1, - double theR2, double theW2, double theL2, - double theH, double theW, - double theRL, double theWL, double theLtransL, double theLthinL, - double theRR, double theWR, double theLtransR, double theLthinR, - double theRI, double theWI, double theLtransI, double theLthinI, - bool theHexMesh = true, - Handle(GEOM_Object) P1 = 0, - Handle(GEOM_Object) P2 = 0, - Handle(GEOM_Object) P3 = 0); - - Standard_EXPORT Handle(TColStd_HSequenceOfTransient) - MakePipeTShapeFillet(double theR1, double theW1, double theL1, - double theR2, double theW2, double theL2, - double theRL, double theWL, double theLtransL, double theLthinL, - double theRR, double theWR, double theLtransR, double theLthinR, - double theRI, double theWI, double theLtransI, double theLthinI, - double theRF, bool theHexMesh = true); - - Standard_EXPORT Handle(TColStd_HSequenceOfTransient) - MakePipeTShapeFilletWithPosition(double theR1, double theW1, double theL1, - double theR2, double theW2, double theL2, - double theRL, double theWL, double theLtransL, double theLthinL, - double theRR, double theWR, double theLtransR, double theLthinR, - double theRI, double theWI, double theLtransI, double theLthinI, - double theRF, bool theHexMesh = true, - Handle(GEOM_Object) P1 = 0, - Handle(GEOM_Object) P2 = 0, - Handle(GEOM_Object) P3 = 0); - - Standard_EXPORT Handle(GEOM_Object) MakeDividedDisk (double theR, double theRatio, - int theOrientation, int thePattern); - Standard_EXPORT Handle(GEOM_Object) MakeDividedDiskPntVecR (Handle(GEOM_Object) thePnt, - Handle(GEOM_Object) theVec, - double theR, - double theRatio, - int thePattern); - - Standard_EXPORT Handle(GEOM_Object) MakeDividedCylinder (double theR, - double theH, - int thePattern); - - Standard_EXPORT Handle(GEOM_Object) MakeSmoothingSurface (std::list thelPoints); - /*@@ insert new functions before this line @@ do not remove this line @@*/ -}; -#endif diff --git a/src/GEOMImpl/GEOMImpl_IDividedDisk.hxx b/src/GEOMImpl/GEOMImpl_IDividedDisk.hxx deleted file mode 100644 index 3d2be4a4f..000000000 --- a/src/GEOMImpl/GEOMImpl_IDividedDisk.hxx +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef _GEOMImpl_IDividedDisk_HXX_ -#define _GEOMImpl_IDividedDisk_HXX_ - -#include "GEOM_Function.hxx" - -#define DIVIDEDDISK_ARG_R 1 -#define DIVIDEDDISK_ARG_RATIO 2 -#define DIVIDEDDISK_ARG_ORIENT 3 - -#define DIVIDEDDISK_ARG_CENTER 4 -#define DIVIDEDDISK_ARG_VECTOR 5 - -#define DIVIDEDDISK_ARG_TYPE 6 - -class GEOMImpl_IDividedDisk -{ -public: - GEOMImpl_IDividedDisk(Handle(GEOM_Function) theFunction): _func(theFunction) {} - - void SetR(double theR) { _func->SetReal(DIVIDEDDISK_ARG_R, theR); } - double GetR() { return _func->GetReal(DIVIDEDDISK_ARG_R); } - - void SetRatio(double theRatio) { _func->SetReal(DIVIDEDDISK_ARG_RATIO, theRatio); } - double GetRatio() { return _func->GetReal(DIVIDEDDISK_ARG_RATIO); } - - void SetOrientation(int theOrientation) { _func->SetInteger(DIVIDEDDISK_ARG_ORIENT, theOrientation); } - int GetOrientation() { return _func->GetInteger(DIVIDEDDISK_ARG_ORIENT); } - - void SetType(int theType) { _func->SetInteger(DIVIDEDDISK_ARG_TYPE, theType); } - int GetType() { return _func->GetInteger(DIVIDEDDISK_ARG_TYPE); } - - void SetCenter(Handle(GEOM_Function) theP) { _func->SetReference(DIVIDEDDISK_ARG_CENTER, theP); } - void SetVector(Handle(GEOM_Function) theV) { _func->SetReference(DIVIDEDDISK_ARG_VECTOR, theV); } - - Handle(GEOM_Function) GetCenter() { return _func->GetReference(DIVIDEDDISK_ARG_CENTER); } - Handle(GEOM_Function) GetVector() { return _func->GetReference(DIVIDEDDISK_ARG_VECTOR); } - -private: - Handle(GEOM_Function) _func; -}; - -#endif // _GEOMImpl_IDividedDisk_HXX_ diff --git a/src/GEOMImpl/GEOMImpl_IPipeTShape.hxx b/src/GEOMImpl/GEOMImpl_IPipeTShape.hxx deleted file mode 100644 index 8d9b60a5b..000000000 --- a/src/GEOMImpl/GEOMImpl_IPipeTShape.hxx +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef _GEOMImpl_IPipeTShape_HXX_ -#define _GEOMImpl_IPipeTShape_HXX_ - -#include "GEOM_Function.hxx" - -#include - -class GEOMImpl_IPipeTShape -{ -public: - GEOMImpl_IPipeTShape(Handle(GEOM_Function) theFunction): _func(theFunction) {} - - void SetR1(double theR1) { _func->SetReal(TSHAPE_ARG_R1, theR1); } - double GetR1() { return _func->GetReal(TSHAPE_ARG_R1); } - - void SetW1(double theW1) { _func->SetReal(TSHAPE_ARG_W1, theW1); } - double GetW1() { return _func->GetReal(TSHAPE_ARG_W1); } - - void SetL1(double theL1) { _func->SetReal(TSHAPE_ARG_L1, theL1); } - double GetL1() { return _func->GetReal(TSHAPE_ARG_L1); } - - void SetR2(double theR2) { _func->SetReal(TSHAPE_ARG_R2, theR2); } - double GetR2() { return _func->GetReal(TSHAPE_ARG_R2); } - - void SetW2(double theW2) { _func->SetReal(TSHAPE_ARG_W2, theW2); } - double GetW2() { return _func->GetReal(TSHAPE_ARG_W2); } - - void SetL2(double theL2) { _func->SetReal(TSHAPE_ARG_L2, theL2); } - double GetL2() { return _func->GetReal(TSHAPE_ARG_L2); } - - void SetH(double theH) { _func->SetReal(TSHAPE_ARG_H, theH); } - double GetH() { return _func->GetReal(TSHAPE_ARG_H); } - - void SetW(double theW) { _func->SetReal(TSHAPE_ARG_W, theW); } - double GetW() { return _func->GetReal(TSHAPE_ARG_W); } - - void SetRF(double theRF) { _func->SetReal(TSHAPE_ARG_RF, theRF); } - double GetRF() { return _func->GetReal(TSHAPE_ARG_RF); } - - void SetHexMesh(int theHexMesh) { _func->SetInteger(TSHAPE_ARG_HEXMESH, theHexMesh); } - int GetHexMesh() { return _func->GetInteger(TSHAPE_ARG_HEXMESH); } - - void SetP1(const Handle(GEOM_Function)& theP1){_func->SetReference(TSHAPE_ARG_P1, theP1); } - Handle(GEOM_Function) GetP1() { return _func->GetReference(TSHAPE_ARG_P1); } - - void SetP2(const Handle(GEOM_Function)& theP2){_func->SetReference(TSHAPE_ARG_P2, theP2); } - Handle(GEOM_Function) GetP2() { return _func->GetReference(TSHAPE_ARG_P2); } - - void SetP3(const Handle(GEOM_Function)& theP3){_func->SetReference(TSHAPE_ARG_P3, theP3); } - Handle(GEOM_Function) GetP3() { return _func->GetReference(TSHAPE_ARG_P3); } - -private: - enum { - // main pipe - TSHAPE_ARG_R1 = 1, - TSHAPE_ARG_W1 = 2, - TSHAPE_ARG_L1 = 3, - - // incident pipe - TSHAPE_ARG_R2 = 4, - TSHAPE_ARG_W2 = 5, - TSHAPE_ARG_L2 = 6, - - // chamfer - TSHAPE_ARG_H = 7, - TSHAPE_ARG_W = 8, - - // fillet - TSHAPE_ARG_RF = 9, - - // partition - TSHAPE_ARG_HEXMESH = 10, - - // junction points - TSHAPE_ARG_P1 = 11, - TSHAPE_ARG_P2 = 12, - TSHAPE_ARG_P3 = 13 - }; - -private: - Handle(GEOM_Function) _func; -}; - -#endif // _GEOMImpl_IPipeTShape_HXX_ diff --git a/src/GEOMImpl/GEOMImpl_ISmoothingSurface.hxx b/src/GEOMImpl/GEOMImpl_ISmoothingSurface.hxx deleted file mode 100644 index 2ca3ac1de..000000000 --- a/src/GEOMImpl/GEOMImpl_ISmoothingSurface.hxx +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com - -#ifndef _GEOMImpl_ISmoothingSurface_HXX_ -#define _GEOMImpl_ISmoothingSurface_HXX_ - -#include "GEOM_Function.hxx" - -#define SMOOTHINGSURFACE_ARG_LENG 1 -#define SMOOTHINGSURFACE_ARG_LAST 2 - -class GEOMImpl_ISmoothingSurface -{ -public: - GEOMImpl_ISmoothingSurface(Handle(GEOM_Function) theFunction): _func(theFunction) {} - - void SetLength(int theLen) { _func->SetInteger(SMOOTHINGSURFACE_ARG_LENG, theLen); } - int GetLength() { return _func->GetInteger(SMOOTHINGSURFACE_ARG_LENG); } - - void SetPoint(int theId, Handle(GEOM_Function) theP) { _func->SetReference(SMOOTHINGSURFACE_ARG_LAST + theId, theP); } - Handle(GEOM_Function) GetPoint(int theId) { return _func->GetReference(SMOOTHINGSURFACE_ARG_LAST + theId); } - -private: - Handle(GEOM_Function) _func; -}; - -#endif // _GEOMImpl_ISmoothingSurface_HXX_ diff --git a/src/GEOMImpl/GEOMImpl_PipeTShapeDriver.cxx b/src/GEOMImpl/GEOMImpl_PipeTShapeDriver.cxx deleted file mode 100644 index 4446e8343..000000000 --- a/src/GEOMImpl/GEOMImpl_PipeTShapeDriver.cxx +++ /dev/null @@ -1,676 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include - -#include -#include -#include -#include - -#include -#include - -#include - -#include -#include -#include - -#include -#include - -// Partition includes -#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 required header files here @@// - -//======================================================================= -//function : GetID -//purpose : -//======================================================================= -const Standard_GUID& GEOMImpl_PipeTShapeDriver::GetID() -{ - static Standard_GUID aGUID("1C3A0F3F-729D-4E83-8232-78E74FC5637C"); - return aGUID; -} - -//======================================================================= -//function : GEOMImpl_PipeTShapeDriver -//purpose : -//======================================================================= -GEOMImpl_PipeTShapeDriver::GEOMImpl_PipeTShapeDriver() -{ -} - -//======================================================================= -//function : getShapesOnBoxIDs - /*! - * \brief Find IDs of sub-shapes complying with given status about surface - * \param theBox - the box to check state of sub-shapes against - * \param theShape - the shape to explore - * \param theShapeType - type of sub-shape of theShape - * \param theState - required state - * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes - */ -//======================================================================= -Handle(TColStd_HSequenceOfInteger) -GEOMImpl_PipeTShapeDriver::GetShapesOnBoxIDs(const TopoDS_Shape& aBox, - const TopoDS_Shape& aShape, - const Standard_Integer theShapeType, - GEOMAlgo_State theState) const -{ - Handle(TColStd_HSequenceOfInteger) aSeqOfIDs; - - // Check presence of triangulation, build if need - if (!GEOMUtils::CheckTriangulation(aShape)) { - StdFail_NotDone::Raise("Cannot build triangulation on the shape"); - return aSeqOfIDs; - } - - // Call algo - GEOMAlgo_FinderShapeOn2 aFinder; - Standard_Real aTol = 0.0001; // default value - - Handle(GEOMAlgo_ClsfBox) aClsfBox = new GEOMAlgo_ClsfBox; - aClsfBox->SetBox(aBox); - - aFinder.SetShape(aShape); - aFinder.SetTolerance(aTol); - aFinder.SetClsf(aClsfBox); - aFinder.SetShapeType( (TopAbs_ShapeEnum)theShapeType ); - aFinder.SetState(theState); - aFinder.Perform(); - - // Interprete results - Standard_Integer iErr = aFinder.ErrorStatus(); - // the detailed description of error codes is in GEOMAlgo_FinderShapeOn1.cxx - if (iErr) { - TCollection_AsciiString aMsg (" iErr : "); - aMsg += TCollection_AsciiString(iErr); - StdFail_NotDone::Raise(aMsg.ToCString()); - return aSeqOfIDs; - } - - - const TopTools_ListOfShape& listSS = aFinder.Shapes(); // the result - - if (listSS.Extent() < 1) { - StdFail_NotDone::Raise(NOT_FOUND_ANY); // NPAL18017 - return aSeqOfIDs; - } - - // Fill sequence of object IDs - aSeqOfIDs = new TColStd_HSequenceOfInteger; - - TopTools_IndexedMapOfShape anIndices; - TopExp::MapShapes(aShape, anIndices); - - TopTools_ListIteratorOfListOfShape itSub (listSS); - for (int index = 1; itSub.More(); itSub.Next(), ++index) { - int id = anIndices.FindIndex(itSub.Value()); -// std::cerr << "Shape with ID " << id << " found" << std::endl; - aSeqOfIDs->Append(id); - } - - return aSeqOfIDs; -} - -//======================================================================= -//function : GetShapesOnSurfaceIDs - /*! - * \brief Find IDs of sub-shapes complying with given status about surface - * \param theSurface - the surface to check state of sub-shapes against - * \param theShape - the shape to explore - * \param theShapeType - type of sub-shape of theShape - * \param theState - required state - * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes - */ -//======================================================================= -Handle(TColStd_HSequenceOfInteger) - GEOMImpl_PipeTShapeDriver::GetShapesOnSurfaceIDs(const Handle(Geom_Surface)& theSurface, - const TopoDS_Shape& theShape, - TopAbs_ShapeEnum theShapeType, - GEOMAlgo_State theState) const -{ - Handle(TColStd_HSequenceOfInteger) aSeqOfIDs; - - // Check presence of triangulation, build if need - if (!GEOMUtils::CheckTriangulation(theShape)) { - StdFail_NotDone::Raise("Cannot build triangulation on the shape"); - return aSeqOfIDs; - } - - // Call algo - GEOMAlgo_FinderShapeOn1 aFinder; - Standard_Real aTol = 1e-6; - - aFinder.SetShape(theShape); - aFinder.SetTolerance(aTol); - aFinder.SetSurface(theSurface); - aFinder.SetShapeType(theShapeType); - aFinder.SetState(theState); - - // Sets the minimal number of inner points for the faces that do not have own - // inner points at all (for e.g. rectangular planar faces have just 2 triangles). - // Default value=3 - aFinder.SetNbPntsMin(3); - // Sets the maximal number of inner points for edges or faces. - // It is usefull for the cases when this number is very big (e.g =2000) to improve - // the performance. If this value =0, all inner points will be taken into account. - // Default value=0 - aFinder.SetNbPntsMax(0); - - aFinder.Perform(); - - // Interprete results - Standard_Integer iErr = aFinder.ErrorStatus(); - // the detailed description of error codes is in GEOMAlgo_FinderShapeOn1.cxx - if (iErr) { -// MESSAGE(" iErr : " << iErr); - TCollection_AsciiString aMsg (" iErr : "); - aMsg += TCollection_AsciiString(iErr); - StdFail_NotDone::Raise(aMsg.ToCString()); - return aSeqOfIDs; - } -// Standard_Integer iWrn = aFinder.WarningStatus(); - // the detailed description of warning codes is in GEOMAlgo_FinderShapeOn1.cxx -// if (iWrn) { -// MESSAGE(" *** iWrn : " << iWrn); -// } - - const TopTools_ListOfShape& listSS = aFinder.Shapes(); // the result - - if (listSS.Extent() < 1) { - //StdFail_NotDone::Raise("Not a single sub-shape of the requested type found on the given surface"); - StdFail_NotDone::Raise(NOT_FOUND_ANY); // NPAL18017 - return aSeqOfIDs; - } - - // Fill sequence of object IDs - aSeqOfIDs = new TColStd_HSequenceOfInteger; - - TopTools_IndexedMapOfShape anIndices; - TopExp::MapShapes(theShape, anIndices); - - TopTools_ListIteratorOfListOfShape itSub (listSS); - for (int index = 1; itSub.More(); itSub.Next(), ++index) { - int id = anIndices.FindIndex(itSub.Value()); - aSeqOfIDs->Append(id); - } - - return aSeqOfIDs; -} - -//======================================================================= -//function : GetCommonShapesOnCylinders -//purpose : return the common shapes between 2 cylindrical surfaces -// along OX and OZ -//======================================================================= -void GEOMImpl_PipeTShapeDriver::GetCommonShapesOnCylinders(const TopoDS_Shape& theShape, - TopAbs_ShapeEnum theShapeType, - double r1, - double r2, - Handle(TopTools_HSequenceOfShape)& commonShapes) const -{ - gp_Pnt aP0 (0, 0, 0); - gp_Vec aVX = gp::DX(), aVZ = gp::DZ(); - gp_Ax3 anAxis1 (aP0, aVX, aVZ), anAxis2 (aP0, aVZ, aVX); - - TopTools_IndexedMapOfShape aMapOfShapes; - aMapOfShapes.Clear(); - TopExp::MapShapes(theShape, aMapOfShapes); - - commonShapes->Clear(); - - int myID; - bool found = false; - - // Create a cylinder surface - Handle(Geom_Surface) aC1Ext = new Geom_CylindricalSurface(anAxis1, r1); - if ( aC1Ext.IsNull() ) - StdFail_NotDone::Raise("Couldn't build main cylindrical surface"); - // Find object IDs - Handle(TColStd_HSequenceOfInteger) aSeqExt1 = GetShapesOnSurfaceIDs( aC1Ext, theShape, theShapeType, GEOMAlgo_ST_ON ); - // Create a cylinder surface - Handle(Geom_Surface) aC2Ext = new Geom_CylindricalSurface(anAxis2, r2); - if ( aC2Ext.IsNull() ) - StdFail_NotDone::Raise("Couldn't build incident cylindrical surface"); - // Find object IDs - Handle(TColStd_HSequenceOfInteger) aSeqExt2 = GetShapesOnSurfaceIDs( aC2Ext, theShape, theShapeType, GEOMAlgo_ST_ON ); - // # Recherche (dans le quart de Te) de l'arete d'intersection des 2 cylindres - // # Search in theShape for common shape of type theShapeType on the intersection of 2 pipes - found = false; - for (int i=1; i<=aSeqExt2->Length();i++) { -// std::cerr << "aSeqExt2->Value(i): " << aSeqExt2->Value(i) << std::endl; - for (int j=1; j<=aSeqExt1->Length();j++) { -// std::cerr << "aSeqExt1->Value(j): " << aSeqExt1->Value(j) << std::endl; - if (aSeqExt1->Value(j) == aSeqExt2->Value(i)) { - myID = aSeqExt1->Value(j); - commonShapes->Append(aMapOfShapes.FindKey(myID)); - found = true; - } - } - } - if (!found) - StdFail_NotDone::Raise("Common shapes couldn't be found"); -} - -//======================================================================= -//function : MakePipeTShape -//purpose : -//======================================================================= -TopoDS_Shape GEOMImpl_PipeTShapeDriver::MakePipeTShape (const double r1, const double w1, const double l1, - const double r2, const double w2, const double l2) const -{ - double r1Ext = r1 + w1; - double r2Ext = r2 + w2; - - gp_Pnt aP0 (0, 0, 0); - gp_Pnt aP1 (-l1, 0, 0); - gp_Vec aVX = gp::DX(), aVY = gp::DY(), aVZ = gp::DZ(); - gp_Ax2 anAxes1 (aP1, aVX, aVZ); - gp_Ax2 anAxes2 (aP0, aVZ, aVX); - - // Build the initial pipes - BRepPrimAPI_MakeCylinder C1Int (anAxes1, r1, Abs(2 * l1)); - BRepPrimAPI_MakeCylinder C1Ext (anAxes1, r1Ext, Abs(2 * l1)); - BRepPrimAPI_MakeCylinder C2Int (anAxes2, r2, Abs(l2)); - BRepPrimAPI_MakeCylinder C2Ext (anAxes2, r2Ext, Abs(l2)); - C1Int.Build(); - C1Ext.Build(); - C2Int.Build(); - C2Ext.Build(); - if (!C1Int.IsDone() || !C1Ext.IsDone() || !C2Int.IsDone() || !C2Ext.IsDone()) { - StdFail_NotDone::Raise("Cannot build cylinders"); - } - - // Fuse the 2 pipes - BRepAlgoAPI_Fuse fuse1 (C1Ext.Shape(), C2Ext.Shape()); - if (!fuse1.IsDone()) { - StdFail_NotDone::Raise("Cannot fuse cylinders"); - } - - // Remove small radius main pipe - BRepAlgoAPI_Cut cut1 (fuse1.Shape(), C1Int.Shape()); - if (!cut1.IsDone()) { - StdFail_NotDone::Raise("Coudn't cut cylinders"); - } - - // Remove small radius incident pipe => Te - BRepAlgoAPI_Cut Te (cut1.Shape(), C2Int.Shape()); - if (!Te.IsDone()) { - StdFail_NotDone::Raise("Coudn't cut cylinders"); - } - - return Te.Shape(); -} - -//======================================================================= -//function : MakeQuarterPipeTShape -//purpose : -//======================================================================= -TopoDS_Shape GEOMImpl_PipeTShapeDriver::MakeQuarterPipeTShape (const double r1, const double w1, const double l1, - const double r2, const double w2, const double l2) const -{ - TopoDS_Shape Te = MakePipeTShape(r1, w1, l1, r2, w2, l2); - if (Te.IsNull()) - StdFail_NotDone::Raise("Couldn't build Pipe TShape"); - - // Get a quarter of shape => Te2 - double r1Ext = r1 + w1; - BRepPrimAPI_MakeBox box1 (gp_Pnt(0, -2*r1Ext, -2*r1Ext), gp_Pnt( Abs(2 * l1), 2*r1Ext, Abs(2*l2))); - BRepPrimAPI_MakeBox box2 (gp_Pnt(0, 2*r1Ext, -2*r1Ext), gp_Pnt(-Abs(2 * l1), 0, Abs(2*l2))); - box1.Build(); - box2.Build(); - if (!box1.IsDone() || !box2.IsDone()) { - StdFail_NotDone::Raise("Couldn't build boxes"); - } - BRepAlgoAPI_Cut cut3 (Te, box1.Shape()); - if (!cut3.IsDone()) { - StdFail_NotDone::Raise("Couldn't cut Pipe Tshape with box"); - } - BRepAlgoAPI_Cut Te4 (cut3.Shape(), box2.Shape()); - if (!Te4.IsDone()) { - StdFail_NotDone::Raise("Couldn't cut Pipe Tshape with box"); - } - - return Te4.Shape(); -} - -//======================================================================= -//function : Execute -//purpose : -//======================================================================= -Standard_Integer GEOMImpl_PipeTShapeDriver::Execute (TFunction_Logbook& log) const -{ - if (Label().IsNull()) return 0; - Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); - - GEOMImpl_IPipeTShape aData (aFunction); - Standard_Integer aType = aFunction->GetType(); - - TopoDS_Shape aShape, Te4, Te4Part; - //TopoDS_Edge arete_intersect_int; - //Handle(TopTools_HSequenceOfShape) edges_e = new TopTools_HSequenceOfShape; - Handle(TColStd_HSequenceOfInteger) edges_e; - //Handle(TopTools_HSequenceOfShape) edges_i = new TopTools_HSequenceOfShape; - //gp_Pnt aP0 (0, 0, 0); - //gp_Vec aVX = gp::DX(), aVY = gp::DY(), aVZ = gp::DZ(); - bool hexMesh = (bool) aData.GetHexMesh(); - - // Useful values - //double aSize = 2*(aData.GetL1() + aData.GetL2()); - double epsilon = Precision::Approximation(); - double aR1Ext = aData.GetR1() + aData.GetW1(); - double aR2Ext = aData.GetR2() + aData.GetW2(); - - if (aData.GetR2() > aData.GetR1() + epsilon) { - StdFail_NotDone::Raise("TShape cannot be computed if R2 > R1"); - } - - if (aR2Ext > aR1Ext + epsilon) { - StdFail_NotDone::Raise("TShape cannot be computed if R2+W2 > R1+W1"); - } - - // external radius are equal - if (fabs(aR2Ext - aR1Ext) < epsilon) { - if (aType == TSHAPE_CHAMFER) - StdFail_NotDone::Raise("TShape with chamfer cannot be computed if R2+W2 = R1+W1"); - if (aType == TSHAPE_FILLET) - StdFail_NotDone::Raise("TShape with fillet cannot be computed if R2+W2 = R1+W1"); - // internal radius are different => not possible - if (fabs(aData.GetR2() - aData.GetR1()) > epsilon) { - StdFail_NotDone::Raise("TShape cannot be computed if R2+W2 = R1+W1 and R2 != R1"); - } - } - - if (aR1Ext >= aData.GetL2() + epsilon) { - StdFail_NotDone::Raise("TShape cannot be computed if R1+W1 >= L2"); - } - if (aR2Ext >= aData.GetL1() + epsilon) { - StdFail_NotDone::Raise("TShape cannot be computed if R2+W2 >= L1"); - } - - if (aType == TSHAPE_CHAMFER) { - if (aData.GetH() >= (aData.GetL2() - aR1Ext + epsilon)) { - StdFail_NotDone::Raise("TShape cannot be computed: height of chamfer is too high"); - } - - if (aData.GetW() >= (aData.GetL1() - aR2Ext + epsilon)) - StdFail_NotDone::Raise("TShape cannot be computed: width of chamfer is too high"); - } - - if (aType == TSHAPE_FILLET) { - if (aData.GetRF() >= (aData.GetL2() - aR1Ext + epsilon) || - aData.GetRF() >= (aData.GetL1() - aR2Ext + epsilon)) - StdFail_NotDone::Raise("TShape cannot be computed: radius of fillet is too high"); - } - - if (hexMesh) { - // Create a quarter of a basic T-Shape pipe - //std::cerr << "Create a quarter of a basic T-Shape pipe" << std::endl; - Te4 = MakeQuarterPipeTShape(aData.GetR1(), aData.GetW1(), aData.GetL1(), - aData.GetR2(), aData.GetW2(), aData.GetL2()); - } - else { - // No need to cut pipe t-shape - //std::cerr << "Create a basic T-Shape pipe" << std::endl; - Te4 = MakePipeTShape(aData.GetR1(), aData.GetW1(), aData.GetL1(), - aData.GetR2(), aData.GetW2(), aData.GetL2()); - } - aShape = Te4; -/* - if (aType == TSHAPE_BASIC) { - aShape = Te4; -// aShape = MakeQuarterPipeTShape(aData.GetR1(), aData.GetW1(), aData.GetL1(), -// aData.GetR2(), aData.GetW2(), aData.GetL2()); - } - else if (aType == TSHAPE_CHAMFER) { - // TShape with chamfer -// BRep_Builder BB; -// TopoDS_Compound CC; -// BB.MakeCompound(CC); - // Create chamfer on the edges edges_e - BRepFilletAPI_MakeChamfer chamfer (Te4); - TopTools_IndexedMapOfShape anEdgesIndices; - TopExp::MapShapes(Te4, anEdgesIndices); - - TopoDS_Shape theBox; - if (hexMesh) { - BRepPrimAPI_MakeBox aBox (gp_Pnt(0,0,0),gp_Pnt(-aR2Ext, -aR2Ext, aR1Ext)); - aBox.Build(); - if (!aBox.IsDone()) { - StdFail_NotDone::Raise("Couldn't build box"); - } - theBox = aBox.Shape(); - } - else { - BRepPrimAPI_MakeBox aBox (gp_Pnt(aR2Ext,aR2Ext,0),gp_Pnt(-aR2Ext, -aR2Ext, aR1Ext)); - aBox.Build(); - if (!aBox.IsDone()) { - StdFail_NotDone::Raise("Couldn't build box"); - } - theBox = aBox.Shape(); - } - Handle(TColStd_HSequenceOfInteger) edges_e = new TColStd_HSequenceOfInteger; - edges_e = GetShapesOnBoxIDs(theBox, Te4, TopAbs_EDGE, GEOMAlgo_ST_IN); - if (edges_e.IsNull() || edges_e->Length() == 0) { - StdFail_NotDone::Raise("Common edges not found"); - } - - TopTools_IndexedDataMapOfShapeListOfShape M; - GEOMImpl_Block6Explorer::MapShapesAndAncestors(Te4, TopAbs_EDGE, TopAbs_FACE, M); -// std::cerr << "Number of IDs: " << edges_e->Length() << std::endl; - int nbEdgesInChamfer = 0; - for (int i=1;i<=edges_e->Length();i++) { -// std::cerr << "Get Edge with ID #" << i << std::endl; - int theId = edges_e->Value(i); -// std::cerr << "ID #" << i << "= " << theId << std::endl; -// std::cerr << "Search for edge in shape" << std::endl; - TopoDS_Edge theEdge = TopoDS::Edge(anEdgesIndices.FindKey(theId)); -// std::cerr << "Found" << std::endl; -// std::cerr << "Keep only edges with a vertex on (x, x, re1)" << std::endl; - TopExp_Explorer ExVertices; - for (ExVertices.Init(theEdge,TopAbs_VERTEX); ExVertices.More(); ExVertices.Next()) { - gp_Pnt aPt = BRep_Tool::Pnt(TopoDS::Vertex(ExVertices.Current())); - if (aPt.Z() - aR1Ext <= epsilon) { -// std::cerr << "aPt.Z() = aR1Ext => keep this edge" << std::endl; - nbEdgesInChamfer ++; - const TopTools_ListOfShape& aFL = M.FindFromKey(theEdge); - TopoDS_Face F = TopoDS::Face( aFL.First() ); - if (hexMesh) - chamfer.Add(aData.GetH(), aData.GetW(), theEdge, F); - else - chamfer.Add(aData.GetW(), aData.GetH(), theEdge, F); - break; - } - } -// std::cerr << "Test if hexMesh: "; - if (hexMesh && nbEdgesInChamfer == 1) { -// std::cerr << "Yes => stop after 1 edge" << std::endl; - break; - } -// std::cerr << "No => continue for other edges" << std::endl; - // BB.Add(CC, edges_e->Value(i)); - // const TopTools_ListOfShape& aFL = M.FindFromKey(TopoDS::Edge(edges_e->Value(i))); - // chamfer.Add(aData.GetW(), aData.GetH(), TopoDS::Edge(edges_e->Value(i)), F); - } -// std::cerr << "Build chamfer with " << nbEdgesInChamfer << " edges" << std::endl; -// } - chamfer.Build(); - if (!chamfer.IsDone()) { - StdFail_NotDone::Raise("Chamfer can not be computed on the given shape with the given parameters"); - } - -// BB.Add(CC, chamfer.Shape()); - -// aShape = CC; - aShape = chamfer.Shape(); - } - else if (aType == TSHAPE_FILLET) { - // TShape with fillet - // Create fillet on the edge arete_intersect_ext - BRepFilletAPI_MakeFillet fill (Te4); - - TopTools_IndexedMapOfShape anIndices; - TopExp::MapShapes(Te4, anIndices); - - TopoDS_Shape theBox; - if (hexMesh) { - BRepPrimAPI_MakeBox aBox (gp_Pnt(0,0,0),gp_Pnt(-aR2Ext, -aR2Ext, aR1Ext)); - aBox.Build(); - if (!aBox.IsDone()) { - StdFail_NotDone::Raise("Couldn't build box"); - } - theBox = aBox.Shape(); - } - else { - BRepPrimAPI_MakeBox aBox (gp_Pnt(aR2Ext,aR2Ext,0),gp_Pnt(-aR2Ext, -aR2Ext, aR1Ext)); - aBox.Build(); - if (!aBox.IsDone()) { - StdFail_NotDone::Raise("Couldn't build box"); - } - theBox = aBox.Shape(); - } - Handle(TColStd_HSequenceOfInteger) edges_e = new TColStd_HSequenceOfInteger; - edges_e = GetShapesOnBoxIDs(theBox, Te4, TopAbs_EDGE, GEOMAlgo_ST_IN); - if (edges_e.IsNull() || edges_e->Length() == 0) { - StdFail_NotDone::Raise("Common edges not found"); - } - -// fill.Add(TopoDS::Edge(edges_e->Value(1))); -// if (!hexMesh) { - for (int i=1;i<=edges_e->Length();i++) { - if (hexMesh && (i > 1)) - break; - TopoDS_Edge theEdge = TopoDS::Edge(anIndices.FindKey(edges_e->Value(i))); - fill.Add(theEdge); -// fill.Add(TopoDS::Edge(edges_e->Value(i))); - } -// } - fill.SetRadius(aData.GetRF(), 1, 1); - fill.Build(); - if (!fill.IsDone()) { - StdFail_NotDone::Raise("Fillet can't be computed on the given shape with the given radius"); - } - - aShape = fill.Shape(); - } - else { - // other construction modes here - } -*/ - if (aShape.IsNull()) return 0; - - aFunction->SetValue(aShape); - - log.SetTouched(Label()); - - return 1; -} - -//================================================================================ -/*! - * \brief Returns a name of creation operation and names and values of creation parameters - */ -//================================================================================ - -bool GEOMImpl_PipeTShapeDriver:: -GetCreationInformation(std::string& theOperationName, - std::vector& theParams) -{ - if (Label().IsNull()) return 0; - Handle(GEOM_Function) function = GEOM_Function::GetFunction(Label()); - - GEOMImpl_IPipeTShape aCI( function ); - Standard_Integer aType = function->GetType(); - - theOperationName = "PIPETSHAPE"; - - switch ( aType ) { - case TSHAPE_BASIC: - AddParam( theParams, "Main radius", aCI.GetR1() ); - AddParam( theParams, "Main width", aCI.GetW1() ); - AddParam( theParams, "Main half-length", aCI.GetL1() ); - AddParam( theParams, "Incident pipe radius", aCI.GetR2() ); - AddParam( theParams, "Incident pipe width", aCI.GetW2() ); - AddParam( theParams, "Incident pipe half-length", aCI.GetL2() ); - AddParam( theParams, "For hex mesh", aCI.GetHexMesh() ); - break; - case TSHAPE_CHAMFER: - AddParam( theParams, "Main radius", aCI.GetR1() ); - AddParam( theParams, "Main width", aCI.GetW1() ); - AddParam( theParams, "Main half-length", aCI.GetL1() ); - AddParam( theParams, "Incident pipe radius", aCI.GetR2() ); - AddParam( theParams, "Incident pipe width", aCI.GetW2() ); - AddParam( theParams, "Incident pipe half-length", aCI.GetL2() ); - AddParam( theParams, "Chamfer height", aCI.GetH() ); - AddParam( theParams, "Chamfer width", aCI.GetW() ); - AddParam( theParams, "For hex mesh", aCI.GetHexMesh() ); - break; - case TSHAPE_FILLET: - AddParam( theParams, "Main radius", aCI.GetR1() ); - AddParam( theParams, "Main width", aCI.GetW1() ); - AddParam( theParams, "Main half-length", aCI.GetL1() ); - AddParam( theParams, "Incident pipe radius", aCI.GetR2() ); - AddParam( theParams, "Incident pipe width", aCI.GetW2() ); - AddParam( theParams, "Incident pipe half-length", aCI.GetL2() ); - AddParam( theParams, "Fillet radius", aCI.GetRF() ); - AddParam( theParams, "For hex mesh", aCI.GetHexMesh() ); - break; - default: - return false; - } - - return true; -} - -IMPLEMENT_STANDARD_HANDLE (GEOMImpl_PipeTShapeDriver,GEOM_BaseDriver); -IMPLEMENT_STANDARD_RTTIEXT (GEOMImpl_PipeTShapeDriver,GEOM_BaseDriver); diff --git a/src/GEOMImpl/GEOMImpl_PipeTShapeDriver.hxx b/src/GEOMImpl/GEOMImpl_PipeTShapeDriver.hxx deleted file mode 100644 index 39396262c..000000000 --- a/src/GEOMImpl/GEOMImpl_PipeTShapeDriver.hxx +++ /dev/null @@ -1,134 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef _GEOMImpl_PipeTShapeDriver_HXX -#define _GEOMImpl_PipeTShapeDriver_HXX - -#include - -#include "GEOMAlgo_State.hxx" - -#include -#include -#include -#include -#include -#include - -#include - -class Handle_Standard_Type; -class GEOMImpl_PipeTShapeDriver; - - - -#include "GEOM_BaseDriver.hxx" - -DEFINE_STANDARD_HANDLE( GEOMImpl_PipeTShapeDriver, GEOM_BaseDriver ); - -class GEOMImpl_PipeTShapeDriver : public GEOM_BaseDriver { -public: - // Methods PUBLIC - // - Standard_EXPORT GEOMImpl_PipeTShapeDriver(); - Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const; - Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {} - Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const - { - return Standard_True; - } - Standard_EXPORT static const Standard_GUID& GetID(); - Standard_EXPORT ~GEOMImpl_PipeTShapeDriver() {}; - - Standard_EXPORT virtual - bool GetCreationInformation(std::string& theOperationName, - std::vector& params); - // Type management - // -DEFINE_STANDARD_RTTI( GEOMImpl_PipeTShapeDriver ) - -private: - - /*! - * \brief Create a T-Shape based on pipes - * \param r1 - the internal radius of main pipe - * \param w1 - the thickness of main pipe - * \param l1 - the half-length of main pipe - * \param r2 - the internal radius of incident pipe - * \param w2 - the thickness of incident pipe - * \param l2 - the half-length of main pipe - * \retval TopoDS_Shape - Resulting shape - */ - TopoDS_Shape MakePipeTShape(double r1, double w1, double l1, - double r2, double w2, double l2) const; - - /*! - * \brief Create a quarter of a T-Shape based on pipes - * \param r1 - the internal radius of main pipe - * \param w1 - the thickness of main pipe - * \param l1 - the half-length of main pipe - * \param r2 - the internal radius of incident pipe - * \param w2 - the thickness of incident pipe - * \param l2 - the half-length of main pipe - * \retval TopoDS_Shape - Resulting shape - */ - TopoDS_Shape MakeQuarterPipeTShape(double r1, double w1, double l1, - double r2, double w2, double l2) const; - - /*! - * \brief Find IDs of sub-shapes complying with given status about surface - * \param theSurface - the surface to check state of sub-shapes against - * \param theShape - the shape to explore - * \param theShapeType - type of sub-shape of theShape - * \param theState - required state - * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes - */ - Handle(TColStd_HSequenceOfInteger) - GetShapesOnSurfaceIDs(const Handle(Geom_Surface)& theSurface, - const TopoDS_Shape& theShape, - TopAbs_ShapeEnum theShapeType, - GEOMAlgo_State theState) const; - - /*! - * \brief Find IDs of sub-shapes complying with given status about surface - * \param theBox - the box to check state of sub-shapes against - * \param theShape - the shape to explore - * \param theShapeType - type of sub-shape of theShape - * \param theState - required state - * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes - */ - Handle(TColStd_HSequenceOfInteger) - GetShapesOnBoxIDs(const TopoDS_Shape& aBox, - const TopoDS_Shape& aShape, - const Standard_Integer theShapeType, - GEOMAlgo_State theState) const; - - //======================================================================= - //function : getCommonShapesOnCylinders - //purpose : return the common edge between 2 cylindrical surfaces - // along OX and OZ - //======================================================================= - void GetCommonShapesOnCylinders(const TopoDS_Shape& theShape, - TopAbs_ShapeEnum theShapeType, - double r, double r2, - Handle(TopTools_HSequenceOfShape)& commonShapes) const; - -}; - -#endif // _GEOMImpl_PipeTShapeDriver_HXX diff --git a/src/GEOMImpl/GEOMImpl_SmoothingSurfaceDriver.cxx b/src/GEOMImpl/GEOMImpl_SmoothingSurfaceDriver.cxx deleted file mode 100644 index 4dbb65b17..000000000 --- a/src/GEOMImpl/GEOMImpl_SmoothingSurfaceDriver.cxx +++ /dev/null @@ -1,230 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com - -#include - -#include -#include -#include -#include - -#include -#include - -//@@ include required header files here @@// -#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 -//======================================================================= -//function : GetID -//purpose : -//======================================================================= -const Standard_GUID& GEOMImpl_SmoothingSurfaceDriver::GetID() -{ - static Standard_GUID aGUID("1C3A0F30-729D-4E83-8232-78E74FC5637C"); - return aGUID; -} - -//======================================================================= -//function : GEOMImpl_SmoothingSurfaceDriver -//purpose : -//======================================================================= -GEOMImpl_SmoothingSurfaceDriver::GEOMImpl_SmoothingSurfaceDriver() -{ -} - -//======================================================================= -//function : MakeSmoothingSurfaceUnClosed -//purpose : -//======================================================================= -TopoDS_Shape GEOMImpl_SmoothingSurfaceDriver::MakeSmoothingSurfaceUnClosed(Handle_TColgp_HArray1OfPnt myListOfPoints) const -{ - TopoDS_Face aInitShape; - - // Create an average Plane - //Handle(TColgp_HArray1OfPnt) HAP = new TColgp_HArray1OfPnt(1,myListOfPoints.Length()) - GeomPlate_BuildAveragePlane gpbap(myListOfPoints,myListOfPoints->Length(),Precision::Confusion(),1,1); - Handle(Geom_Plane) plane(gpbap.Plane()); - Standard_Real Umin, Umax, Vmin, Vmax; - gpbap.MinMaxBox(Umin,Umax,Vmin,Vmax); - // cout << "Vals : " << Umin << ", " << Umax << ", " << Vmin << ", " << Vmax << endl; - BRepBuilderAPI_MakeFace mf(plane,Umin,Umax,Vmin,Vmax,Precision::Confusion()); - aInitShape = mf.Face(); - //return aInitShape; - - GeomPlate_BuildPlateSurface aBuilder(3,10); - // ** Initialization of surface - Handle(BRepAdaptor_HSurface) HSI = new BRepAdaptor_HSurface(); - HSI->ChangeSurface().Initialize(aInitShape); - aBuilder.LoadInitSurface( BRep_Tool::Surface(HSI->ChangeSurface().Face())); - - Standard_Integer j, j1, j2; - // cout << "Init surface" << endl; - j1 = myListOfPoints->Lower(); - j2 = myListOfPoints->Upper(); - for (j=j1; j<=j2 ; j++) - { - gp_Pnt aPnt = myListOfPoints->Value(j); - Handle(GeomPlate_PointConstraint) PCont = new GeomPlate_PointConstraint(aPnt,0); - aBuilder.Add(PCont); - } - // cout << "avant Perform surface" << endl; - aBuilder.Perform(); - // cout << "Perform surface" << endl; - - // A ce niveau : surface algo - Handle(GeomPlate_Surface) gpPlate = aBuilder.Surface(); - - Standard_Integer nbcarreau=2; - Standard_Integer degmax=8; - Standard_Real seuil; - seuil = Max(0.0001,10*aBuilder.G0Error()); - GeomPlate_MakeApprox Mapp(gpPlate,0.0001,nbcarreau,degmax,seuil); - // cout << "Approx surface" << endl; - - Handle (Geom_Surface) Surf (Mapp.Surface()); - - aBuilder.Surface()->Bounds( Umin, Umax, Vmin, Vmax); - - BRepBuilderAPI_MakeFace MF(Surf,Umin, Umax, Vmin, Vmax, Precision::Confusion()); - TopoDS_Shape aShape = MF.Shape(); - - return aShape; -} - - -//======================================================================= -//function : Execute -//purpose : -//======================================================================= -Standard_Integer GEOMImpl_SmoothingSurfaceDriver::Execute(TFunction_Logbook& log) const -{ - if (Label().IsNull()) return 0; - Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); - if (aFunction.IsNull()) return 0; - - Standard_Integer aType = aFunction->GetType(); - - if (aType != SMOOTHINGSURFACE_LPOINTS) return 0; - // cout << "Youhou : " << aType << endl; - - GEOMImpl_ISmoothingSurface aData (aFunction); - - Standard_Integer nbPoints = aData.GetLength(); - - Handle(TColgp_HArray1OfPnt) anArrayofPnt = new TColgp_HArray1OfPnt(1,nbPoints); - for (int ind=1;ind<=nbPoints;ind++) - { - Handle(GEOM_Function) aPoint = aData.GetPoint(ind); - TopoDS_Shape aShapePnt = aPoint->GetValue(); - TopoDS_Vertex dsPoint; - dsPoint = TopoDS::Vertex( aShapePnt ); - gp_Pnt aPnt = BRep_Tool::Pnt( dsPoint ); - anArrayofPnt->SetValue(ind,aPnt); - } - - TopoDS_Shape aShape; - aShape = GEOMImpl_SmoothingSurfaceDriver::MakeSmoothingSurfaceUnClosed(anArrayofPnt); - - if (aShape.IsNull()) return 0; - - aFunction->SetValue(aShape); - - log.SetTouched(Label()); - - return 1; -} - -//================================================================================ -/*! - * \brief Returns a name of creation operation and names and values of creation parameters - */ -//================================================================================ - -bool GEOMImpl_SmoothingSurfaceDriver:: -GetCreationInformation(std::string& theOperationName, - std::vector& theParams) -{ - if (Label().IsNull()) return 0; - Handle(GEOM_Function) function = GEOM_Function::GetFunction(Label()); - - GEOMImpl_ISmoothingSurface aCI( function ); - Standard_Integer aType = function->GetType(); - - theOperationName = "SMOOTHINGSURFACE"; - - switch ( aType ) { - case SMOOTHINGSURFACE_LPOINTS: - AddParam( theParams, "Points" ); - if ( aCI.GetLength() > 1 ) - theParams[0] << aCI.GetLength() << " points: "; - for ( int i = 1, nb = aCI.GetLength(); i <= nb; ++i ) - theParams[0] << aCI.GetPoint( i ) << " "; - break; - default: - return false; - } - - return true; -} - -IMPLEMENT_STANDARD_HANDLE (GEOMImpl_SmoothingSurfaceDriver,GEOM_BaseDriver); -IMPLEMENT_STANDARD_RTTIEXT (GEOMImpl_SmoothingSurfaceDriver,GEOM_BaseDriver); diff --git a/src/GEOMImpl/GEOMImpl_SmoothingSurfaceDriver.hxx b/src/GEOMImpl/GEOMImpl_SmoothingSurfaceDriver.hxx deleted file mode 100644 index 3559fcc45..000000000 --- a/src/GEOMImpl/GEOMImpl_SmoothingSurfaceDriver.hxx +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com - -#ifndef _GEOMImpl_SmoothingSurfaceDriver_HXX -#define _GEOMImpl_SmoothingSurfaceDriver_HXX - -#ifndef _TFunction_Driver_HeaderFile -#include -#endif -#ifndef _TFunction_Logbook_HeaderFile -#include -#endif -#ifndef _Standard_CString_HeaderFile -#include -#endif -#include -#include - -class Handle_Standard_Type; -class GEOMImpl_SmoothingSurfaceDriver; - - - -#include "GEOM_BaseDriver.hxx" - -DEFINE_STANDARD_HANDLE( GEOMImpl_SmoothingSurfaceDriver, GEOM_BaseDriver ); - -class GEOMImpl_SmoothingSurfaceDriver : public GEOM_BaseDriver { -public: - // Methods PUBLIC - // - Standard_EXPORT GEOMImpl_SmoothingSurfaceDriver(); - Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const; - Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {} - Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const - { - return Standard_True; - } - Standard_EXPORT static const Standard_GUID& GetID(); - Standard_EXPORT ~GEOMImpl_SmoothingSurfaceDriver() {}; - - Standard_EXPORT virtual - bool GetCreationInformation(std::string& theOperationName, - std::vector& params); - // Type management - // -DEFINE_STANDARD_RTTI( GEOMImpl_SmoothingSurfaceDriver ) - -private: - TopoDS_Shape MakeSmoothingSurfaceUnClosed(Handle_TColgp_HArray1OfPnt myListOfPoints) const; -}; - -#endif // _GEOMImpl_SmoothingSurfaceDriver_HXX diff --git a/src/GEOMImpl/GEOMImpl_Types.hxx b/src/GEOMImpl/GEOMImpl_Types.hxx index a1056d69a..d4884912b 100755 --- a/src/GEOMImpl/GEOMImpl_Types.hxx +++ b/src/GEOMImpl/GEOMImpl_Types.hxx @@ -50,8 +50,6 @@ #define GEOM_CIRC_ARC 19 #define GEOM_FILLET 20 -#define GEOM_FILLET_2D 45 -#define GEOM_FILLET_1D 46 #define GEOM_CHAMFER 21 #define GEOM_EDGE 22 @@ -105,6 +103,9 @@ #define GEOM_THICKENING 49 +#define GEOM_FILLET_2D 50 +#define GEOM_FILLET_1D 51 + //GEOM_Function types #define COPY_WITH_REF 1 @@ -353,17 +354,3 @@ // Advanced functions (base = 200) #define ADVANCED_BASE 200 // NO OPERATION (advanced operations base) -#define GEOM_TSHAPE 201 -#define GEOM_DIVIDEDDISK 202 -#define GEOM_DIVIDEDCYLINDER 203 -#define GEOM_SMOOTHINGSURFACE 204 -/*@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@*/ -// Advanced functions sub-operations codes -#define TSHAPE_BASIC 1 -#define TSHAPE_CHAMFER 2 -#define TSHAPE_FILLET 3 -#define DIVIDEDDISK_R_RATIO 1 -#define DIVIDEDDISK_R_VECTOR_PNT 2 -#define DIVIDEDCYLINDER_R_H 1 -#define SMOOTHINGSURFACE_LPOINTS 1 -/*@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@*/ diff --git a/src/GEOMImpl/Makefile.am b/src/GEOMImpl/Makefile.am index f4a04e8d7..a20ee6e2e 100644 --- a/src/GEOMImpl/Makefile.am +++ b/src/GEOMImpl/Makefile.am @@ -43,7 +43,6 @@ salomeinclude_HEADERS = \ GEOMImpl_IInsertOperations.hxx \ GEOMImpl_IMeasureOperations.hxx \ GEOMImpl_IGroupOperations.hxx \ - GEOMImpl_IAdvancedOperations.hxx \ GEOMImpl_IGlue.hxx \ GEOMImpl_PointDriver.hxx \ GEOMImpl_IPoint.hxx \ @@ -146,15 +145,6 @@ salomeinclude_HEADERS = \ GEOMImpl_Types.hxx \ GEOM_GEOMImpl.hxx -ADVANCED_INCLUDES = -ADVANCED_INCLUDES += GEOMImpl_IPipeTShape.hxx GEOMImpl_PipeTShapeDriver.hxx -ADVANCED_INCLUDES += GEOMImpl_IDividedDisk.hxx GEOMImpl_DividedDiskDriver.hxx -##ADVANCED_INCLUDES += GEOMImpl_IDividedCylinder.hxx GEOMImpl_DividedCylinderDriver.hxx -ADVANCED_INCLUDES += GEOMImpl_ISmoothingSurface.hxx GEOMImpl_SmoothingSurfaceDriver.hxx -##@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@## - -salomeinclude_HEADERS += $(ADVANCED_INCLUDES) - dist_libGEOMimpl_la_SOURCES = \ GEOMImpl_IBasicOperations.cxx \ GEOMImpl_ITransformOperations.cxx \ @@ -168,7 +158,6 @@ dist_libGEOMimpl_la_SOURCES = \ GEOMImpl_IInsertOperations.cxx \ GEOMImpl_IMeasureOperations.cxx \ GEOMImpl_IGroupOperations.cxx \ - GEOMImpl_IAdvancedOperations.cxx \ GEOMImpl_Gen.cxx \ GEOMImpl_PointDriver.cxx \ GEOMImpl_VectorDriver.cxx \ @@ -220,15 +209,6 @@ dist_libGEOMimpl_la_SOURCES = \ GEOMImpl_FillingDriver.cxx \ GEOMImpl_GlueDriver.cxx -ADVANCED_SOURCES = -ADVANCED_SOURCES += GEOMImpl_PipeTShapeDriver.cxx -ADVANCED_SOURCES += GEOMImpl_DividedDiskDriver.cxx -##ADVANCED_SOURCES += GEOMImpl_DividedCylinderDriver.cxx -ADVANCED_SOURCES += GEOMImpl_SmoothingSurfaceDriver.cxx -##@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@## - -dist_libGEOMimpl_la_SOURCES += $(ADVANCED_SOURCES) - # additional information to compile and link file libGEOMimpl_la_CPPFLAGS = \ diff --git a/src/GEOM_I/GEOM_Gen_i.cc b/src/GEOM_I/GEOM_Gen_i.cc index 3026120cc..c44b639c7 100644 --- a/src/GEOM_I/GEOM_Gen_i.cc +++ b/src/GEOM_I/GEOM_Gen_i.cc @@ -18,7 +18,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// #ifdef WNT #pragma warning( disable:4786 ) @@ -64,6 +63,25 @@ #include #include +#ifdef WNT + #include + #include +#else + #include +#endif + +#ifdef WNT + #define LibHandle HMODULE + #define LoadLib( name ) LoadLibrary( name ) + #define GetProc GetProcAddress + #define UnLoadLib( handle ) FreeLibrary( handle ); +#else + #define LibHandle void* + #define LoadLib( name ) dlopen( name, RTLD_LAZY ) + #define GetProc dlsym + #define UnLoadLib( handle ) dlclose( handle ); +#endif + //============================================================================ // function : GEOM_Gen_i() // purpose : constructor to be called for servant creation. @@ -243,30 +261,30 @@ SALOMEDS::SObject_ptr GEOM_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy, } else { GEOM::shape_type myshapetype=aShape->GetShapeType(); if ( myshapetype == GEOM::COMPOUND ) { - aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_COMPOUND" ); - aShapeName = "Compound_"; - } else if ( myshapetype == GEOM::COMPSOLID ) { - aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_COMPSOLID"); - aShapeName = "Compsolid_"; - } else if ( myshapetype == GEOM::SOLID ) { - aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_SOLID"); - aShapeName = "Solid_"; - } else if ( myshapetype == GEOM::SHELL ) { - aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_SHELL"); - aShapeName = "Shell_"; - } else if ( myshapetype == GEOM::FACE ) { - aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_FACE"); - aShapeName = "Face_"; - } else if ( myshapetype == GEOM::WIRE ) { - aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_WIRE"); - aShapeName = "Wire_"; - } else if ( myshapetype == GEOM::EDGE ) { - aResultSO->SetAttrString("AttributePixMap", "ICON_OBJBROWSER_EDGE"); - aShapeName = "Edge_"; - } else if ( myshapetype == GEOM::VERTEX ) { - aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_VERTEX" ); - aShapeName = "Vertex_"; - } + aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_COMPOUND" ); + aShapeName = "Compound_"; + } else if ( myshapetype == GEOM::COMPSOLID ) { + aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_COMPSOLID"); + aShapeName = "Compsolid_"; + } else if ( myshapetype == GEOM::SOLID ) { + aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_SOLID"); + aShapeName = "Solid_"; + } else if ( myshapetype == GEOM::SHELL ) { + aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_SHELL"); + aShapeName = "Shell_"; + } else if ( myshapetype == GEOM::FACE ) { + aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_FACE"); + aShapeName = "Face_"; + } else if ( myshapetype == GEOM::WIRE ) { + aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_WIRE"); + aShapeName = "Wire_"; + } else if ( myshapetype == GEOM::EDGE ) { + aResultSO->SetAttrString("AttributePixMap", "ICON_OBJBROWSER_EDGE"); + aShapeName = "Edge_"; + } else if ( myshapetype == GEOM::VERTEX ) { + aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_VERTEX" ); + aShapeName = "Vertex_"; + } } //if (strlen(theName) == 0) aShapeName += TCollection_AsciiString(aResultSO->Tag()); //else aShapeName = TCollection_AsciiString(CORBA::string_dup(theName)); @@ -2316,22 +2334,78 @@ GEOM::GEOM_IGroupOperations_ptr GEOM_Gen_i::GetIGroupOperations(CORBA::Long theS } //============================================================================ -// function : GetIAdvancedOperations +// function : GetPluginOperations // purpose : //============================================================================ -GEOM::GEOM_IAdvancedOperations_ptr GEOM_Gen_i::GetIAdvancedOperations(CORBA::Long theStudyID) +GEOM::GEOM_IOperations_ptr GEOM_Gen_i::GetPluginOperations(CORBA::Long theStudyID, + const char* theLibName) throw ( SALOME::SALOME_Exception ) { + std::string aPlatformLibName; +#ifdef WNT + aPlatformLibName = theLibName; + aPlatformLibName += ".dll" ; +#else + aPlatformLibName = "lib"; + aPlatformLibName += theLibName; + aPlatformLibName += ".so"; +#endif + Unexpect aCatch(SALOME_SalomeException); - MESSAGE( "GEOM_Gen_i::GetIAdvancedOperations" ); + MESSAGE( "GEOM_Gen_i::GetPluginOperations" ); GEOM::GEOM_Gen_ptr engine = _this(); - GEOM_IAdvancedOperations_i* aServant = - new GEOM_IAdvancedOperations_i(_poa, engine, _impl->GetIAdvancedOperations(theStudyID)); + GEOM_IOperations_i* aServant = 0; + GEOM::GEOM_IOperations_var operations; + + try { + // check, if corresponding operations are already created + if (myOpCreatorMap.find(std::string(theLibName)) == myOpCreatorMap.end()) { + // load plugin library + LibHandle libHandle = LoadLib( aPlatformLibName.c_str()/*theLibName*/ ); + if (!libHandle) { + // report any error, if occured +#ifndef WNT + const char* anError = dlerror(); + throw(SALOME_Exception(anError)); +#else + throw(SALOME_Exception(LOCALIZED( "Can't load server geometry plugin library" ))); +#endif + } + + // get method, returning operations creator + typedef GEOM_GenericOperationsCreator* (*GetOperationsCreator)(); + GetOperationsCreator procHandle = + (GetOperationsCreator)GetProc( libHandle, "GetOperationsCreator" ); + if (!procHandle) { + throw(SALOME_Exception(LOCALIZED("bad geometry plugin library"))); + UnLoadLib(libHandle); + } + + // get operations creator + GEOM_GenericOperationsCreator* aCreator = procHandle(); + if (!aCreator) { + throw(SALOME_Exception(LOCALIZED("bad geometry plugin library implementation"))); + } + + // map operations creator to a plugin name + myOpCreatorMap[std::string(theLibName)] = aCreator; + } + + // create a new operations object, store its ref. in engine + aServant = myOpCreatorMap[std::string(theLibName)]->Create(_poa, theStudyID, engine, _impl); + //??? aServant->SetLibName(aPlatformLibName/*theLibName*/); // for persistency assurance + } + catch (SALOME_Exception& S_ex) { + THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM); + } + + if (!aServant) + return operations._retn(); // activate the CORBA servant - GEOM::GEOM_IAdvancedOperations_var operations = aServant->_this(); + operations = GEOM::GEOM_IOperations::_narrow( aServant->_this() ); return operations._retn(); } diff --git a/src/GEOM_I/GEOM_Gen_i.hh b/src/GEOM_I/GEOM_Gen_i.hh index 0b264cfd0..c87fe23cf 100644 --- a/src/GEOM_I/GEOM_Gen_i.hh +++ b/src/GEOM_I/GEOM_Gen_i.hh @@ -18,7 +18,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// #ifndef __GEOM_GEN_I_H__ #define __GEOM_GEN_I_H__ @@ -50,16 +49,31 @@ #include "GEOM_IInsertOperations_i.hh" #include "GEOM_IMeasureOperations_i.hh" #include "GEOM_IGroupOperations_i.hh" -#include "GEOM_IAdvancedOperations_i.hh" #include +#include #include #include //#include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC +//===================================================================== +// Generic operations creator (for plugins mechanism) +//===================================================================== +class GEOM_I_EXPORT GEOM_GenericOperationsCreator +{ +public: + // Create operations + virtual GEOM_IOperations_i* Create (PortableServer::POA_ptr thePOA, + int theStudyId, + GEOM::GEOM_Gen_ptr theEngine, + ::GEOMImpl_Gen* theGenImpl) = 0; + // return the name of IDL module + //virtual std::string GetModuleName() = 0; +}; + //===================================================================== // GEOM_Gen_i : class definition //===================================================================== @@ -242,8 +256,9 @@ class GEOM_I_EXPORT GEOM_Gen_i: virtual public POA_GEOM::GEOM_Gen, virtual publi virtual GEOM::GEOM_IGroupOperations_ptr GetIGroupOperations (CORBA::Long theStudyID) throw (SALOME::SALOME_Exception); - //Returns a pointer to AdvancedOperations interface - virtual GEOM::GEOM_IAdvancedOperations_ptr GetIAdvancedOperations (CORBA::Long theStudyID) + //Returns a pointer to corresponding plugin operations interface + virtual GEOM::GEOM_IOperations_ptr GetPluginOperations (CORBA::Long theStudyID, + const char* theLibName) throw (SALOME::SALOME_Exception); //Adds a new sub-shape @@ -342,6 +357,9 @@ class GEOM_I_EXPORT GEOM_Gen_i: virtual public POA_GEOM::GEOM_Gen, virtual publi ::GEOMImpl_Gen* _impl; SALOME_NamingService * name_service; char * _name; + + // plugin operations managing + std::map myOpCreatorMap; }; #endif diff --git a/src/GEOM_I/GEOM_IAdvancedOperations_i.cc b/src/GEOM_I/GEOM_IAdvancedOperations_i.cc deleted file mode 100644 index 1fe516222..000000000 --- a/src/GEOM_I/GEOM_IAdvancedOperations_i.cc +++ /dev/null @@ -1,785 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -// File : GEOM_IAdvancedOperations.cc -// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) - -#include - -#include "GEOM_IAdvancedOperations_i.hh" - -#include -#include -#include - -#include "GEOM_Engine.hxx" -#include "GEOM_Object.hxx" - -//============================================================================= -/*! - * constructor: - */ -//============================================================================= -GEOM_IAdvancedOperations_i::GEOM_IAdvancedOperations_i(PortableServer::POA_ptr thePOA, GEOM::GEOM_Gen_ptr theEngine, ::GEOMImpl_IAdvancedOperations* theImpl) -:GEOM_IOperations_i(thePOA, theEngine, theImpl) -{ - MESSAGE("GEOM_IAdvancedOperations_i::GEOM_IAdvancedOperations_i"); -} - -//============================================================================= -/*! - * destructor - */ -//============================================================================= -GEOM_IAdvancedOperations_i::~GEOM_IAdvancedOperations_i() -{ - MESSAGE("GEOM_IAdvancedOperations_i::~GEOM_IAdvancedOperations_i"); -} - -//============================================================================= -/*! - * MakePipeTShape - * Create a T-shape object with specified caracteristics for the main and - * the incident pipes (radius, width, half-length). - * Center of the shape is (0,0,0). The main plane of the T-shape is XOY. - * \param theR1 Internal radius of main pipe - * \param theW1 Width of main pipe - * \param theL1 Half-length of main pipe - * \param theR2 Internal radius of incident pipe (R2 < R1) - * \param theW2 Width of incident pipe (R2+W2 < R1+W1) - * \param theL2 Half-length of incident pipe - * \param theHexMesh Boolean indicating if shape is prepared for hex mesh - * \return List of GEOM_Objects, containing the created shape and propagation groups. - */ -//============================================================================= -GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShape - (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, - CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, - CORBA::Boolean theHexMesh) -{ - GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; - - //Set a not done flag - GetOperations()->SetNotDone(); - - //Create the TShape - Handle(TColStd_HSequenceOfTransient) aHSeq = - GetOperations()->MakePipeTShape(theR1, theW1, theL1, theR2, theW2, theL2, - 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., - theHexMesh); - if (!GetOperations()->IsDone() || aHSeq.IsNull()) - return aSeq._retn(); - - Standard_Integer aLength = aHSeq->Length(); - aSeq->length(aLength); - for (Standard_Integer i = 1; i <= aLength; i++) - aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i))); - - return aSeq._retn(); -} - -//============================================================================= -/*! - * MakePipeTShapeWithPosition - * Create a T-shape object with specified caracteristics for the main and - * the incident pipes (radius, width, half-length). - * The extremities of the main pipe are located on junctions points P1 and P2. - * The extremity of the incident pipe is located on junction point P3. - * \param theR1 Internal radius of main pipe - * \param theW1 Width of main pipe - * \param theL1 Half-length of main pipe - * \param theR2 Internal radius of incident pipe (R2 < R1) - * \param theW2 Width of incident pipe (R2+W2 < R1+W1) - * \param theL2 Half-length of incident pipe - * \param theHexMesh Boolean indicating if shape is prepared for hex mesh - * \param theP1 1st junction point of main pipe - * \param theP2 2nd junction point of main pipe - * \param theP3 Junction point of incident pipe - * \return List of GEOM_Objects, containing the created shape and propagation groups. - */ -//============================================================================= -GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeWithPosition - (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, - CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, - CORBA::Boolean theHexMesh, - GEOM::GEOM_Object_ptr theP1, GEOM::GEOM_Object_ptr theP2, GEOM::GEOM_Object_ptr theP3) -{ - GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; - - //Set a not done flag - GetOperations()->SetNotDone(); - - //Get the reference vertices - Handle(GEOM_Object) aP1 = GetObjectImpl(theP1); - Handle(GEOM_Object) aP2 = GetObjectImpl(theP2); - Handle(GEOM_Object) aP3 = GetObjectImpl(theP3); - if (aP1.IsNull() || aP2.IsNull() || aP3.IsNull())return aSeq._retn(); - - //Create the TShape - Handle(TColStd_HSequenceOfTransient) aHSeq = - GetOperations()->MakePipeTShapeWithPosition(theR1, theW1, theL1, theR2, theW2, theL2, - 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., - theHexMesh, aP1, aP2, aP3); - if (!GetOperations()->IsDone() || aHSeq.IsNull()) - return aSeq._retn(); - - Standard_Integer aLength = aHSeq->Length(); - aSeq->length(aLength); - for (Standard_Integer i = 1; i <= aLength; i++) - aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i))); - - return aSeq._retn(); -} - -//============================================================================= -/*! - * MakePipeTShapeChamfer - * Create a T-shape object with specified caracteristics for the main and - * the incident pipes (radius, width, half-length). A chamfer is created - * on the junction of the pipes. - * Center of the shape is (0,0,0). The main plane of the T-shape is XOY. - * \param theR1 Internal radius of main pipe - * \param theW1 Width of main pipe - * \param theL1 Half-length of main pipe - * \param theR2 Internal radius of incident pipe (R2 < R1) - * \param theW2 Width of incident pipe (R2+W2 < R1+W1) - * \param theL2 Half-length of incident pipe - * \param theH Height of chamfer. - * \param theW Width of chamfer. - * \param theHexMesh Boolean indicating if shape is prepared for hex mesh - * \return List of GEOM_Objects, containing the created shape and propagation groups. - */ -//============================================================================= -GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeChamfer - (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, - CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, - CORBA::Double theH, CORBA::Double theW, CORBA::Boolean theHexMesh) -{ - GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; - - //Set a not done flag - GetOperations()->SetNotDone(); - - //Create the TShape - Handle(TColStd_HSequenceOfTransient) aHSeq = - GetOperations()->MakePipeTShapeChamfer(theR1, theW1, theL1, theR2, theW2, theL2, - 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., - theH, theW, theHexMesh); - if (!GetOperations()->IsDone() || aHSeq.IsNull()) - return aSeq._retn(); - - Standard_Integer aLength = aHSeq->Length(); - aSeq->length(aLength); - for (Standard_Integer i = 1; i <= aLength; i++) - aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i))); - - return aSeq._retn(); -} - -//============================================================================= -/*! - * MakePipeTShapeChamferWithPosition - * Create a T-shape object with specified caracteristics for the main and - * the incident pipes (radius, width, half-length). A chamfer is created - * on the junction of the pipes. - * The extremities of the main pipe are located on junctions points P1 and P2. - * The extremity of the incident pipe is located on junction point P3. - * \param theR1 Internal radius of main pipe - * \param theW1 Width of main pipe - * \param theL1 Half-length of main pipe - * \param theR2 Internal radius of incident pipe (R2 < R1) - * \param theW2 Width of incident pipe (R2+W2 < R1+W1) - * \param theL2 Half-length of incident pipe - * \param theH Height of the chamfer. - * \param theW Width of the chamfer. - * \param theHexMesh Boolean indicating if shape is prepared for hex mesh - * \param theP1 1st junction point of main pipe - * \param theP2 2nd junction point of main pipe - * \param theP3 Junction point of incident pipe - * \return List of GEOM_Objects, containing the created shape and propagation groups. - */ -//============================================================================= -GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeChamferWithPosition - (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, - CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, - CORBA::Double theH, CORBA::Double theW, CORBA::Boolean theHexMesh, - GEOM::GEOM_Object_ptr theP1, GEOM::GEOM_Object_ptr theP2, GEOM::GEOM_Object_ptr theP3) -{ - GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; - - //Set a not done flag - GetOperations()->SetNotDone(); - - //Get the reference vertices - Handle(GEOM_Object) aP1 = GetObjectImpl(theP1); - Handle(GEOM_Object) aP2 = GetObjectImpl(theP2); - Handle(GEOM_Object) aP3 = GetObjectImpl(theP3); - - //Create the TShape - Handle(TColStd_HSequenceOfTransient) aHSeq = - GetOperations()->MakePipeTShapeChamferWithPosition(theR1, theW1, theL1, theR2, theW2, theL2, - 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., - theH, theW, theHexMesh, aP1, aP2, aP3); - if (!GetOperations()->IsDone() || aHSeq.IsNull()) - return aSeq._retn(); - - Standard_Integer aLength = aHSeq->Length(); - aSeq->length(aLength); - for (Standard_Integer i = 1; i <= aLength; i++) - aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i))); - - return aSeq._retn(); -} - -//============================================================================= -/*! - * MakePipeTShapeFillet - * Create a T-shape object with specified caracteristics for the main and - * the incident pipes (radius, width, half-length). A fillet is created - * on the junction of the pipes. - * Center of the shape is (0,0,0). The main plane of the T-shape is XOY. - * \param theR1 Internal radius of main pipe - * \param theW1 Width of main pipe - * \param theL1 Half-length of main pipe - * \param theR2 Internal radius of incident pipe (R2 < R1) - * \param theW2 Width of incident pipe (R2+W2 < R1+W1) - * \param theL2 Half-length of incident pipe - * \param theRF Radius of curvature of fillet. - * \param theHexMesh Boolean indicating if shape is prepared for hex mesh - * \return List of GEOM_Objects, containing the created shape and propagation groups. - */ -//============================================================================= -GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeFillet - (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, - CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, - CORBA::Double theRF, CORBA::Boolean theHexMesh) -{ - GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; - - //Set a not done flag - GetOperations()->SetNotDone(); - - //Create the TShape - Handle(TColStd_HSequenceOfTransient) aHSeq = - GetOperations()->MakePipeTShapeFillet(theR1, theW1, theL1, theR2, theW2, theL2, - 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., - theRF, theHexMesh); - if (!GetOperations()->IsDone() || aHSeq.IsNull()) - return aSeq._retn(); - - Standard_Integer aLength = aHSeq->Length(); - aSeq->length(aLength); - for (Standard_Integer i = 1; i <= aLength; i++) - aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i))); - - return aSeq._retn(); -} - -//============================================================================= -/*! - * MakePipeTShapeFilletWithPosition - * Create a T-shape object with specified caracteristics for the main and - * the incident pipes (radius, width, half-length). A fillet is created - * on the junction of the pipes. - * The extremities of the main pipe are located on junctions points P1 and P2. - * The extremity of the incident pipe is located on junction point P3. - * \param theR1 Internal radius of main pipe - * \param theW1 Width of main pipe - * \param theL1 Half-length of main pipe - * \param theR2 Internal radius of incident pipe (R2 < R1) - * \param theW2 Width of incident pipe (R2+W2 < R1+W1) - * \param theL2 Half-length of incident pipe - * \param theRF Radius of curvature of fillet - * \param theHexMesh Boolean indicating if shape is prepared for hex mesh - * \param theP1 1st junction point of main pipe - * \param theP2 2nd junction point of main pipe - * \param theP3 Junction point of incident pipe - * \return List of GEOM_Objects, containing the created shape and propagation groups. - */ -//============================================================================= -GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeFilletWithPosition - (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, - CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, - CORBA::Double theRF, CORBA::Boolean theHexMesh, - GEOM::GEOM_Object_ptr theP1, GEOM::GEOM_Object_ptr theP2, GEOM::GEOM_Object_ptr theP3) -{ - GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; - - //Set a not done flag - GetOperations()->SetNotDone(); - - //Get the reference vertices - Handle(GEOM_Object) aP1 = GetObjectImpl(theP1); - Handle(GEOM_Object) aP2 = GetObjectImpl(theP2); - Handle(GEOM_Object) aP3 = GetObjectImpl(theP3); - - //Create the TShape - Handle(TColStd_HSequenceOfTransient) aHSeq = - GetOperations()->MakePipeTShapeFilletWithPosition(theR1, theW1, theL1, theR2, theW2, theL2, - 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., - theRF, theHexMesh, aP1, aP2, aP3); - if (!GetOperations()->IsDone() || aHSeq.IsNull()) - return aSeq._retn(); - - Standard_Integer aLength = aHSeq->Length(); - aSeq->length(aLength); - for (Standard_Integer i = 1; i <= aLength; i++) - aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i))); - - return aSeq._retn(); -} - -//============================================================================= -/*! - * MakePipeTShapeTR - * Create a T-shape object with specified caracteristics for the main and - * the incident pipes (radius, width, half-length). - * Center of the shape is (0,0,0). The main plane of the T-shape is XOY. - * \param theR1 Internal radius of main pipe - * \param theW1 Width of main pipe - * \param theL1 Half-length of main pipe - * \param theR2 Internal radius of incident pipe (R2 < R1) - * \param theW2 Width of incident pipe (R2+W2 < R1+W1) - * \param theL2 Half-length of incident pipe - * \param theHexMesh Boolean indicating if shape is prepared for hex mesh - * \return List of GEOM_Objects, containing the created shape and propagation groups. - */ -//============================================================================= -GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeTR - (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, - CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, - CORBA::Double theRL, CORBA::Double theWL, CORBA::Double theLtransL, CORBA::Double theLthinL, - CORBA::Double theRR, CORBA::Double theWR, CORBA::Double theLtransR, CORBA::Double theLthinR, - CORBA::Double theRI, CORBA::Double theWI, CORBA::Double theLtransI, CORBA::Double theLthinI, - CORBA::Boolean theHexMesh) -{ - GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; - - //Set a not done flag - GetOperations()->SetNotDone(); - - //Create the TShape - Handle(TColStd_HSequenceOfTransient) aHSeq = - GetOperations()->MakePipeTShape(theR1, theW1, theL1, theR2, theW2, theL2, - theRL, theWL, theLtransL, theLthinL, - theRR, theWR, theLtransR, theLthinR, - theRI, theWI, theLtransI, theLthinI, - theHexMesh); - if (!GetOperations()->IsDone() || aHSeq.IsNull()) - return aSeq._retn(); - - Standard_Integer aLength = aHSeq->Length(); - aSeq->length(aLength); - for (Standard_Integer i = 1; i <= aLength; i++) - aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i))); - - return aSeq._retn(); -} - -//============================================================================= -/*! - * MakePipeTShapeTRWithPosition - * Create a T-shape object with specified caracteristics for the main and - * the incident pipes (radius, width, half-length). - * The extremities of the main pipe are located on junctions points P1 and P2. - * The extremity of the incident pipe is located on junction point P3. - * \param theR1 Internal radius of main pipe - * \param theW1 Width of main pipe - * \param theL1 Half-length of main pipe - * \param theR2 Internal radius of incident pipe (R2 < R1) - * \param theW2 Width of incident pipe (R2+W2 < R1+W1) - * \param theL2 Half-length of incident pipe - * \param theHexMesh Boolean indicating if shape is prepared for hex mesh - * \param theP1 1st junction point of main pipe - * \param theP2 2nd junction point of main pipe - * \param theP3 Junction point of incident pipe - * \return List of GEOM_Objects, containing the created shape and propagation groups. - */ -//============================================================================= -GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeTRWithPosition - (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, - CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, - CORBA::Double theRL, CORBA::Double theWL, CORBA::Double theLtransL, CORBA::Double theLthinL, - CORBA::Double theRR, CORBA::Double theWR, CORBA::Double theLtransR, CORBA::Double theLthinR, - CORBA::Double theRI, CORBA::Double theWI, CORBA::Double theLtransI, CORBA::Double theLthinI, - CORBA::Boolean theHexMesh, - GEOM::GEOM_Object_ptr theP1, GEOM::GEOM_Object_ptr theP2, GEOM::GEOM_Object_ptr theP3) -{ - GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; - - //Set a not done flag - GetOperations()->SetNotDone(); - - //Get the reference vertices - Handle(GEOM_Object) aP1 = GetObjectImpl(theP1); - Handle(GEOM_Object) aP2 = GetObjectImpl(theP2); - Handle(GEOM_Object) aP3 = GetObjectImpl(theP3); - if (aP1.IsNull() || aP2.IsNull() || aP3.IsNull()) return aSeq._retn(); - - //Create the TShape - Handle(TColStd_HSequenceOfTransient) aHSeq = - GetOperations()->MakePipeTShapeWithPosition(theR1, theW1, theL1, theR2, theW2, theL2, - theRL, theWL, theLtransL, theLthinL, - theRR, theWR, theLtransR, theLthinR, - theRI, theWI, theLtransI, theLthinI, - theHexMesh, aP1, aP2, aP3); - if (!GetOperations()->IsDone() || aHSeq.IsNull()) - return aSeq._retn(); - - Standard_Integer aLength = aHSeq->Length(); - aSeq->length(aLength); - for (Standard_Integer i = 1; i <= aLength; i++) - aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i))); - - return aSeq._retn(); -} - -//============================================================================= -/*! - * MakePipeTShapeTRChamfer - * Create a T-shape object with specified caracteristics for the main and - * the incident pipes (radius, width, half-length). A chamfer is created - * on the junction of the pipes. - * Center of the shape is (0,0,0). The main plane of the T-shape is XOY. - * \param theR1 Internal radius of main pipe - * \param theW1 Width of main pipe - * \param theL1 Half-length of main pipe - * \param theR2 Internal radius of incident pipe (R2 < R1) - * \param theW2 Width of incident pipe (R2+W2 < R1+W1) - * \param theL2 Half-length of incident pipe - * \param theH Height of chamfer. - * \param theW Width of chamfer. - * \param theHexMesh Boolean indicating if shape is prepared for hex mesh - * \return List of GEOM_Objects, containing the created shape and propagation groups. - */ -//============================================================================= -GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeTRChamfer - (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, - CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, - CORBA::Double theRL, CORBA::Double theWL, CORBA::Double theLtransL, CORBA::Double theLthinL, - CORBA::Double theRR, CORBA::Double theWR, CORBA::Double theLtransR, CORBA::Double theLthinR, - CORBA::Double theRI, CORBA::Double theWI, CORBA::Double theLtransI, CORBA::Double theLthinI, - CORBA::Double theH, CORBA::Double theW, CORBA::Boolean theHexMesh) -{ - GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; - - //Set a not done flag - GetOperations()->SetNotDone(); - - //Create the TShape - Handle(TColStd_HSequenceOfTransient) aHSeq = - GetOperations()->MakePipeTShapeChamfer(theR1, theW1, theL1, theR2, theW2, theL2, - theRL, theWL, theLtransL, theLthinL, - theRR, theWR, theLtransR, theLthinR, - theRI, theWI, theLtransI, theLthinI, - theH, theW, theHexMesh); - if (!GetOperations()->IsDone() || aHSeq.IsNull()) - return aSeq._retn(); - - Standard_Integer aLength = aHSeq->Length(); - aSeq->length(aLength); - for (Standard_Integer i = 1; i <= aLength; i++) - aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i))); - - return aSeq._retn(); -} - -//============================================================================= -/*! - * MakePipeTShapeTRChamferWithPosition - * Create a T-shape object with specified caracteristics for the main and - * the incident pipes (radius, width, half-length). A chamfer is created - * on the junction of the pipes. - * The extremities of the main pipe are located on junctions points P1 and P2. - * The extremity of the incident pipe is located on junction point P3. - * \param theR1 Internal radius of main pipe - * \param theW1 Width of main pipe - * \param theL1 Half-length of main pipe - * \param theR2 Internal radius of incident pipe (R2 < R1) - * \param theW2 Width of incident pipe (R2+W2 < R1+W1) - * \param theL2 Half-length of incident pipe - * \param theH Height of the chamfer. - * \param theW Width of the chamfer. - * \param theHexMesh Boolean indicating if shape is prepared for hex mesh - * \param theP1 1st junction point of main pipe - * \param theP2 2nd junction point of main pipe - * \param theP3 Junction point of incident pipe - * \return List of GEOM_Objects, containing the created shape and propagation groups. - */ -//============================================================================= -GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeTRChamferWithPosition - (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, - CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, - CORBA::Double theRL, CORBA::Double theWL, CORBA::Double theLtransL, CORBA::Double theLthinL, - CORBA::Double theRR, CORBA::Double theWR, CORBA::Double theLtransR, CORBA::Double theLthinR, - CORBA::Double theRI, CORBA::Double theWI, CORBA::Double theLtransI, CORBA::Double theLthinI, - CORBA::Double theH, CORBA::Double theW, CORBA::Boolean theHexMesh, - GEOM::GEOM_Object_ptr theP1, GEOM::GEOM_Object_ptr theP2, GEOM::GEOM_Object_ptr theP3) -{ - GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; - - //Set a not done flag - GetOperations()->SetNotDone(); - - //Get the reference vertices - Handle(GEOM_Object) aP1 = GetObjectImpl(theP1); - Handle(GEOM_Object) aP2 = GetObjectImpl(theP2); - Handle(GEOM_Object) aP3 = GetObjectImpl(theP3); - - //Create the TShape - Handle(TColStd_HSequenceOfTransient) aHSeq = - GetOperations()->MakePipeTShapeChamferWithPosition(theR1, theW1, theL1, theR2, theW2, theL2, - theRL, theWL, theLtransL, theLthinL, - theRR, theWR, theLtransR, theLthinR, - theRI, theWI, theLtransI, theLthinI, - theH, theW, theHexMesh, aP1, aP2, aP3); - if (!GetOperations()->IsDone() || aHSeq.IsNull()) - return aSeq._retn(); - - Standard_Integer aLength = aHSeq->Length(); - aSeq->length(aLength); - for (Standard_Integer i = 1; i <= aLength; i++) - aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i))); - - return aSeq._retn(); -} - -//============================================================================= -/*! - * MakePipeTShapeTRFillet - * Create a T-shape object with specified caracteristics for the main and - * the incident pipes (radius, width, half-length). A fillet is created - * on the junction of the pipes. - * Center of the shape is (0,0,0). The main plane of the T-shape is XOY. - * \param theR1 Internal radius of main pipe - * \param theW1 Width of main pipe - * \param theL1 Half-length of main pipe - * \param theR2 Internal radius of incident pipe (R2 < R1) - * \param theW2 Width of incident pipe (R2+W2 < R1+W1) - * \param theL2 Half-length of incident pipe - * \param theRF Radius of curvature of fillet. - * \param theHexMesh Boolean indicating if shape is prepared for hex mesh - * \return List of GEOM_Objects, containing the created shape and propagation groups. - */ -//============================================================================= -GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeTRFillet - (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, - CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, - CORBA::Double theRL, CORBA::Double theWL, CORBA::Double theLtransL, CORBA::Double theLthinL, - CORBA::Double theRR, CORBA::Double theWR, CORBA::Double theLtransR, CORBA::Double theLthinR, - CORBA::Double theRI, CORBA::Double theWI, CORBA::Double theLtransI, CORBA::Double theLthinI, - CORBA::Double theRF, CORBA::Boolean theHexMesh) -{ - GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; - - //Set a not done flag - GetOperations()->SetNotDone(); - - //Create the TShape - Handle(TColStd_HSequenceOfTransient) aHSeq = - GetOperations()->MakePipeTShapeFillet(theR1, theW1, theL1, theR2, theW2, theL2, - theRL, theWL, theLtransL, theLthinL, - theRR, theWR, theLtransR, theLthinR, - theRI, theWI, theLtransI, theLthinI, - theRF, theHexMesh); - if (!GetOperations()->IsDone() || aHSeq.IsNull()) - return aSeq._retn(); - - Standard_Integer aLength = aHSeq->Length(); - aSeq->length(aLength); - for (Standard_Integer i = 1; i <= aLength; i++) - aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i))); - - return aSeq._retn(); -} - -//============================================================================= -/*! - * MakePipeTShapeTRFilletWithPosition - * Create a T-shape object with specified caracteristics for the main and - * the incident pipes (radius, width, half-length). A fillet is created - * on the junction of the pipes. - * The extremities of the main pipe are located on junctions points P1 and P2. - * The extremity of the incident pipe is located on junction point P3. - * \param theR1 Internal radius of main pipe - * \param theW1 Width of main pipe - * \param theL1 Half-length of main pipe - * \param theR2 Internal radius of incident pipe (R2 < R1) - * \param theW2 Width of incident pipe (R2+W2 < R1+W1) - * \param theL2 Half-length of incident pipe - * \param theRF Radius of curvature of fillet - * \param theHexMesh Boolean indicating if shape is prepared for hex mesh - * \param theP1 1st junction point of main pipe - * \param theP2 2nd junction point of main pipe - * \param theP3 Junction point of incident pipe - * \return List of GEOM_Objects, containing the created shape and propagation groups. - */ -//============================================================================= -GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeTRFilletWithPosition - (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, - CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, - CORBA::Double theRL, CORBA::Double theWL, CORBA::Double theLtransL, CORBA::Double theLthinL, - CORBA::Double theRR, CORBA::Double theWR, CORBA::Double theLtransR, CORBA::Double theLthinR, - CORBA::Double theRI, CORBA::Double theWI, CORBA::Double theLtransI, CORBA::Double theLthinI, - CORBA::Double theRF, CORBA::Boolean theHexMesh, - GEOM::GEOM_Object_ptr theP1, GEOM::GEOM_Object_ptr theP2, GEOM::GEOM_Object_ptr theP3) -{ - GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; - - //Set a not done flag - GetOperations()->SetNotDone(); - - //Get the reference vertices - Handle(GEOM_Object) aP1 = GetObjectImpl(theP1); - Handle(GEOM_Object) aP2 = GetObjectImpl(theP2); - Handle(GEOM_Object) aP3 = GetObjectImpl(theP3); - - //Create the TShape - Handle(TColStd_HSequenceOfTransient) aHSeq = - GetOperations()->MakePipeTShapeFilletWithPosition(theR1, theW1, theL1, theR2, theW2, theL2, - theRL, theWL, theLtransL, theLthinL, - theRR, theWR, theLtransR, theLthinR, - theRI, theWI, theLtransI, theLthinI, - theRF, theHexMesh, aP1, aP2, aP3); - if (!GetOperations()->IsDone() || aHSeq.IsNull()) - return aSeq._retn(); - - Standard_Integer aLength = aHSeq->Length(); - aSeq->length(aLength); - for (Standard_Integer i = 1; i <= aLength; i++) - aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i))); - - return aSeq._retn(); -} - -//============================================================================= -/*! - * This function allows to create a disk already divided into blocks. It can be - * use to create divided pipes for later meshing in hexaedra. - * \param theR Radius of the disk - * \param theRatio Relative size of the central square diagonal against the disk diameter - * \return New GEOM_Object, containing the created shape. - */ -//============================================================================= -GEOM::GEOM_Object_ptr GEOM_IAdvancedOperations_i::MakeDividedDisk (CORBA::Double theR, - CORBA::Double theRatio, - CORBA::Short theOrientation, - GEOM::pattern thePattern) -{ - GEOM::GEOM_Object_var aGEOMObject; - - //Set a not done flag - GetOperations()->SetNotDone(); - - //Create the DividedDisk - Handle(GEOM_Object) anObject = GetOperations()->MakeDividedDisk(theR, theRatio, theOrientation, thePattern); - if (!GetOperations()->IsDone() || anObject.IsNull()) - return aGEOMObject._retn(); - - return GetObject(anObject); -} - -//============================================================================= -/*! - * MakeDividedDiskPntVecR - */ -//============================================================================= -GEOM::GEOM_Object_ptr GEOM_IAdvancedOperations_i::MakeDividedDiskPntVecR (GEOM::GEOM_Object_ptr thePnt, - GEOM::GEOM_Object_ptr theVec, - CORBA::Double theR, - CORBA::Double theRatio, - GEOM::pattern thePattern) -{ - GEOM::GEOM_Object_var aGEOMObject; - - //Set a not done flag - GetOperations()->SetNotDone(); - - //Get the reference points - Handle(GEOM_Object) aPnt = GetObjectImpl(thePnt); - Handle(GEOM_Object) aVec = GetObjectImpl(theVec); - - if (aPnt.IsNull() || aVec.IsNull()) return aGEOMObject._retn(); - - // Make DividedDisk - Handle(GEOM_Object) anObject = - GetOperations()->MakeDividedDiskPntVecR(aPnt, aVec, theR, theRatio, thePattern); - if (!GetOperations()->IsDone() || anObject.IsNull()) - return aGEOMObject._retn(); - - return GetObject(anObject); -} - -//============================================================================= -/*! - * Builds a cylinder prepared for hexa meshes - * \param theR Radius of the cylinder - * \param theH Height of the cylinder - * \return New GEOM_Object, containing the created shape. - */ -//============================================================================= -GEOM::GEOM_Object_ptr GEOM_IAdvancedOperations_i::MakeDividedCylinder (CORBA::Double theR, - CORBA::Double theH, - GEOM::pattern thePattern) -{ - GEOM::GEOM_Object_var aGEOMObject; - - //Set a not done flag - GetOperations()->SetNotDone(); - - //Create the DividedCylinder - Handle(GEOM_Object) anObject = GetOperations()->MakeDividedCylinder(theR, theH, thePattern); - if (!GetOperations()->IsDone() || anObject.IsNull()) - return aGEOMObject._retn(); - - return GetObject(anObject); -} - -//============================================================================= -/*! - * - * \param thelPoints list of points - * \return New GEOM_Object, containing the created shape. - */ -//============================================================================= -GEOM::GEOM_Object_ptr GEOM_IAdvancedOperations_i::MakeSmoothingSurface (const GEOM::ListOfGO& thelPoints) -{ - GEOM::GEOM_Object_var aGEOMObject; - - //Set a not done flag - GetOperations()->SetNotDone(); - - //Get the reference point - int ind = 0; - int aLen = thelPoints.length(); - std::list aPoints; - for (; ind < aLen; ind++) { - Handle(GEOM_Object) aPnt = GetObjectImpl(thelPoints[ind]); - if (aPnt.IsNull()) return aGEOMObject._retn(); - aPoints.push_back(aPnt); - } - //Create the SmoothingSurface - Handle(GEOM_Object) anObject = GetOperations()->MakeSmoothingSurface(aPoints); - if (!GetOperations()->IsDone() || anObject.IsNull()) - return aGEOMObject._retn(); - - return GetObject(anObject); -} - -/*@@ insert new functions before this line @@ do not remove this line @@*/ diff --git a/src/GEOM_I/GEOM_IAdvancedOperations_i.hh b/src/GEOM_I/GEOM_IAdvancedOperations_i.hh deleted file mode 100644 index 151049e8c..000000000 --- a/src/GEOM_I/GEOM_IAdvancedOperations_i.hh +++ /dev/null @@ -1,136 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -// File : GEOM_IAdvancedOperations.hh -// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) - -#ifndef _GEOM_IAdvancedOperations_i_HeaderFile -#define _GEOM_IAdvancedOperations_i_HeaderFile - -#include "GEOMImpl_Gen.hxx" - -#include - -#include CORBA_SERVER_HEADER(GEOM_Gen) -#include "GEOM_IOperations_i.hh" -#include "GEOM_Object_i.hh" - -#include "GEOMImpl_IAdvancedOperations.hxx" - -class GEOM_I_EXPORT GEOM_IAdvancedOperations_i : - public virtual POA_GEOM::GEOM_IAdvancedOperations, - public virtual GEOM_IOperations_i -{ - public: - GEOM_IAdvancedOperations_i (PortableServer::POA_ptr thePOA, GEOM::GEOM_Gen_ptr theEngine, - ::GEOMImpl_IAdvancedOperations* theImpl); - ~GEOM_IAdvancedOperations_i(); - - // PipeTShape without thickness reduction - GEOM::ListOfGO* MakePipeTShape (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, - CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, - CORBA::Boolean theHexMesh); - GEOM::ListOfGO* MakePipeTShapeWithPosition (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, - CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, - CORBA::Boolean theHexMesh, - GEOM::GEOM_Object_ptr theP1, GEOM::GEOM_Object_ptr theP2, GEOM::GEOM_Object_ptr theP3); - GEOM::ListOfGO* MakePipeTShapeChamfer (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, - CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, - CORBA::Double theH, CORBA::Double theW, CORBA::Boolean theHexMesh); - GEOM::ListOfGO* MakePipeTShapeChamferWithPosition (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, - CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, - CORBA::Double theH, CORBA::Double theW, CORBA::Boolean theHexMesh, - GEOM::GEOM_Object_ptr theP1, GEOM::GEOM_Object_ptr theP2, GEOM::GEOM_Object_ptr theP3); - GEOM::ListOfGO* MakePipeTShapeFillet (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, - CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, - CORBA::Double theRF, CORBA::Boolean theHexMesh); - GEOM::ListOfGO* MakePipeTShapeFilletWithPosition (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, - CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, - CORBA::Double theRF, CORBA::Boolean theHexMesh, - GEOM::GEOM_Object_ptr theP1, GEOM::GEOM_Object_ptr theP2, GEOM::GEOM_Object_ptr theP3); - - // PipeTShape with thickness reduction - GEOM::ListOfGO* MakePipeTShapeTR - (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, - CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, - CORBA::Double theRL, CORBA::Double theWL, CORBA::Double theLtransL, CORBA::Double theLthinL, - CORBA::Double theRR, CORBA::Double theWR, CORBA::Double theLtransR, CORBA::Double theLthinR, - CORBA::Double theRI, CORBA::Double theWI, CORBA::Double theLtransI, CORBA::Double theLthinI, - CORBA::Boolean theHexMesh); - GEOM::ListOfGO* MakePipeTShapeTRWithPosition - (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, - CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, - CORBA::Double theRL, CORBA::Double theWL, CORBA::Double theLtransL, CORBA::Double theLthinL, - CORBA::Double theRR, CORBA::Double theWR, CORBA::Double theLtransR, CORBA::Double theLthinR, - CORBA::Double theRI, CORBA::Double theWI, CORBA::Double theLtransI, CORBA::Double theLthinI, - CORBA::Boolean theHexMesh, - GEOM::GEOM_Object_ptr theP1, GEOM::GEOM_Object_ptr theP2, GEOM::GEOM_Object_ptr theP3); - GEOM::ListOfGO* MakePipeTShapeTRChamfer - (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, - CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, - CORBA::Double theRL, CORBA::Double theWL, CORBA::Double theLtransL, CORBA::Double theLthinL, - CORBA::Double theRR, CORBA::Double theWR, CORBA::Double theLtransR, CORBA::Double theLthinR, - CORBA::Double theRI, CORBA::Double theWI, CORBA::Double theLtransI, CORBA::Double theLthinI, - CORBA::Double theH, CORBA::Double theW, CORBA::Boolean theHexMesh); - GEOM::ListOfGO* MakePipeTShapeTRChamferWithPosition - (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, - CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, - CORBA::Double theRL, CORBA::Double theWL, CORBA::Double theLtransL, CORBA::Double theLthinL, - CORBA::Double theRR, CORBA::Double theWR, CORBA::Double theLtransR, CORBA::Double theLthinR, - CORBA::Double theRI, CORBA::Double theWI, CORBA::Double theLtransI, CORBA::Double theLthinI, - CORBA::Double theH, CORBA::Double theW, CORBA::Boolean theHexMesh, - GEOM::GEOM_Object_ptr theP1, GEOM::GEOM_Object_ptr theP2, GEOM::GEOM_Object_ptr theP3); - GEOM::ListOfGO* MakePipeTShapeTRFillet - (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, - CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, - CORBA::Double theRL, CORBA::Double theWL, CORBA::Double theLtransL, CORBA::Double theLthinL, - CORBA::Double theRR, CORBA::Double theWR, CORBA::Double theLtransR, CORBA::Double theLthinR, - CORBA::Double theRI, CORBA::Double theWI, CORBA::Double theLtransI, CORBA::Double theLthinI, - CORBA::Double theRF, CORBA::Boolean theHexMesh); - GEOM::ListOfGO* MakePipeTShapeTRFilletWithPosition - (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, - CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, - CORBA::Double theRL, CORBA::Double theWL, CORBA::Double theLtransL, CORBA::Double theLthinL, - CORBA::Double theRR, CORBA::Double theWR, CORBA::Double theLtransR, CORBA::Double theLthinR, - CORBA::Double theRI, CORBA::Double theWI, CORBA::Double theLtransI, CORBA::Double theLthinI, - CORBA::Double theRF, CORBA::Boolean theHexMesh, - GEOM::GEOM_Object_ptr theP1, GEOM::GEOM_Object_ptr theP2, GEOM::GEOM_Object_ptr theP3); - - GEOM::GEOM_Object_ptr MakeDividedDisk (CORBA::Double theR, - CORBA::Double theRatio, - CORBA::Short theOrientation, - GEOM::pattern thePattern); - - GEOM::GEOM_Object_ptr MakeDividedDiskPntVecR (GEOM::GEOM_Object_ptr theCenter, - GEOM::GEOM_Object_ptr theVector, - CORBA::Double theR, - CORBA::Double theRatio, - GEOM::pattern thePattern); - - GEOM::GEOM_Object_ptr MakeDividedCylinder (CORBA::Double theR, - CORBA::Double theH, - GEOM::pattern thePattern); - GEOM::GEOM_Object_ptr MakeSmoothingSurface (const GEOM::ListOfGO& thelPoints); - /*@@ insert new functions before this line @@ do not remove this line @@*/ - - ::GEOMImpl_IAdvancedOperations* GetOperations() - { return (::GEOMImpl_IAdvancedOperations*)GetImpl(); } -}; - -#endif diff --git a/src/GEOM_I/Makefile.am b/src/GEOM_I/Makefile.am index a64d9537e..4dee78ed9 100644 --- a/src/GEOM_I/Makefile.am +++ b/src/GEOM_I/Makefile.am @@ -44,7 +44,6 @@ salomeinclude_HEADERS = \ GEOM_ITransformOperations_i.hh \ GEOM_IMeasureOperations_i.hh \ GEOM_IGroupOperations_i.hh \ - GEOM_IAdvancedOperations_i.hh \ GEOM_Gen_i.hh \ GEOM_GEOM_I.hxx \ GEOM_wrap.hxx @@ -64,7 +63,6 @@ dist_libGEOMEngine_la_SOURCES = \ GEOM_ITransformOperations_i.cc \ GEOM_IMeasureOperations_i.cc \ GEOM_IGroupOperations_i.cc \ - GEOM_IAdvancedOperations_i.cc \ GEOM_Gen_i.cc \ GEOM_DumpPython.cc diff --git a/src/GEOM_I_Superv/GEOM_Superv_i.cc b/src/GEOM_I_Superv/GEOM_Superv_i.cc index ab8c5798e..556910df6 100644 --- a/src/GEOM_I_Superv/GEOM_Superv_i.cc +++ b/src/GEOM_I_Superv/GEOM_Superv_i.cc @@ -398,8 +398,9 @@ void GEOM_Superv_i::getAdvancedOp() if (CORBA::is_nil(myAdvancedOp) || isNewStudy(myLastStudyID,myStudyID)) { //rnv: to fix bug "IPAL22461 6.3.0: Incorrect study storage if study contains shape modified with YACS" // Try to get id of the study from the SALOME Session - if(myStudyID < 0 ) SetStudyID(-1); - myAdvancedOp = myGeomEngine->GetIAdvancedOperations(myStudyID); + if(myStudyID < 0 ) SetStudyID(-1); + //myAdvancedOp = myGeomEngine->GetIAdvancedOperations(myStudyID); + myAdvancedOp = GEOM::GEOM_IAdvancedOperations::_narrow(myGeomEngine->GetPluginOperations(myStudyID, "AdvancedEngine")); } } diff --git a/src/GEOM_SWIG/geomBuilder.py b/src/GEOM_SWIG/geomBuilder.py index 40715da11..2e71559e6 100644 --- a/src/GEOM_SWIG/geomBuilder.py +++ b/src/GEOM_SWIG/geomBuilder.py @@ -459,6 +459,18 @@ class info: CLOSED = 1 UNCLOSED = 2 +##! Private class used to bind calls of plugin operations to geomBuilder +class PluginOperation: + def __init__(self, operation, function): + self.operation = operation + self.function = function + pass + + def __call__(self, *args): + res = self.function(self.operation, *args) + RaiseIfFailed(self.function.__name__, self.operation) + return res + # Warning: geom is a singleton geom = None engine = None @@ -684,13 +696,28 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): self.MeasuOp = self.GetIMeasureOperations (self.myStudyId) self.BlocksOp = self.GetIBlocksOperations (self.myStudyId) self.GroupOp = self.GetIGroupOperations (self.myStudyId) - self.AdvOp = self.GetIAdvancedOperations (self.myStudyId) + #self.AdvOp = self.GetIAdvancedOperations (self.myStudyId) + self.AdvOp = self.GetPluginOperations (self.myStudyId, "AdvancedEngine") # set GEOM as root in the use case tree self.myUseCaseBuilder = self.myStudy.GetUseCaseBuilder() self.myUseCaseBuilder.SetRootCurrent() self.myUseCaseBuilder.Append(self.father) pass + def GetPluginOperations(self, studyID, libraryName): + op = GEOM._objref_GEOM_Gen.GetPluginOperations(self, studyID, libraryName) + if op: + # bind methods of operations to self + methods = op.__class__.__dict__['__methods__'] + avoid_methods = self.BasicOp.__class__.__dict__['__methods__'] + for meth_name in methods: + if not meth_name in avoid_methods: # avoid basic methods + function = getattr(op.__class__, meth_name) + if callable(function): + #self.__dict__[meth_name] = self.__PluginOperation(op, function) + self.__dict__[meth_name] = PluginOperation(op, function) + return op + ## Enable / disable results auto-publishing # # The automatic publishing is managed in the following way: diff --git a/src/Makefile.am b/src/Makefile.am index 1c2ba31d1..a473cc47a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -34,7 +34,8 @@ if GEOM_ENABLE_GUI SUBDIRS += OBJECT DlgRef GEOMFiltersSelection Material GEOMGUI GEOMBase \ GEOMToolsGUI DisplayGUI BasicGUI PrimitiveGUI GenerationGUI \ EntityGUI BuildGUI BooleanGUI TransformationGUI OperationGUI \ - RepairGUI MeasureGUI GroupGUI BlocksGUI AdvancedGUI GEOM_SWIG_WITHIHM + RepairGUI MeasureGUI GroupGUI BlocksGUI AdvancedGUI AdvancedEngine \ + GEOM_SWIG_WITHIHM endif DIST_SUBDIRS = ARCHIMEDE NMTDS NMTTools BlockFix GEOMAlgo SKETCHER \ @@ -45,4 +46,4 @@ DIST_SUBDIRS = ARCHIMEDE NMTDS NMTTools BlockFix GEOMAlgo SKETCHER \ GEOMToolsGUI DisplayGUI BasicGUI PrimitiveGUI GenerationGUI \ EntityGUI BuildGUI BooleanGUI TransformationGUI OperationGUI \ RepairGUI MeasureGUI GroupGUI BlocksGUI AdvancedGUI \ - GEOM_SWIG_WITHIHM GEOM_PY ShapeRecognition + AdvancedEngine GEOM_SWIG_WITHIHM GEOM_PY ShapeRecognition