mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2024-12-25 17:00:35 +05:00
0022766: [EDF] Transport of names
This commit is contained in:
parent
c85f63b521
commit
cceb7b5b9e
BIN
doc/salome/gui/GEOM/images/transfer_data1.png
Normal file
BIN
doc/salome/gui/GEOM/images/transfer_data1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 19 KiB |
BIN
doc/salome/gui/GEOM/images/transfer_data2.png
Normal file
BIN
doc/salome/gui/GEOM/images/transfer_data2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.4 KiB |
53
doc/salome/gui/GEOM/input/transfer_data.doc
Normal file
53
doc/salome/gui/GEOM/input/transfer_data.doc
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
/*!
|
||||||
|
|
||||||
|
\page transfer_data_page Transfer Data
|
||||||
|
|
||||||
|
This operation performs copying of non-topological data
|
||||||
|
from one shape to another. The topology of the destination object
|
||||||
|
will not change, only non-topological data will be transferred
|
||||||
|
(if it is present in the source object). It is possible to transfer
|
||||||
|
the following data with this operation:
|
||||||
|
<ul>
|
||||||
|
<li> <b>Names</b></li>
|
||||||
|
<li> <b>Materials</b></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
To use this operation, select in the Main Menu <b>Operations -> Transfer Data</b>.
|
||||||
|
The following dialog box will appear.
|
||||||
|
|
||||||
|
\image html transfer_data1.png "Transfer Data Dialog"
|
||||||
|
|
||||||
|
In this dialog:
|
||||||
|
<ul>
|
||||||
|
<li> <b>Source Shape</b> is an object that is a source of non-topological data.</li>
|
||||||
|
<li> <b>Destination Shape</b> is a data destination object. </li>
|
||||||
|
<li> <b>Type of detection operation</b> is the method to search sub-shapes of
|
||||||
|
<b>Source Shape</b> in <b>Destination Shape</b>. Data are transferred
|
||||||
|
from these corresponding sub-shapes. This is a combo-box with the following
|
||||||
|
possible values:
|
||||||
|
<ul>
|
||||||
|
<li><b>Get In Place</b> - current implementation of Get In Place algorithm
|
||||||
|
(default value).</li>
|
||||||
|
<li><b>Get In Place (old)</b> - old implementation of Get In Place
|
||||||
|
algorithm.</li>
|
||||||
|
<li><b>Get In Place By History</b> - Get In Place By History algorithm.</li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
To copy data click on \b Apply or <b>Apply and Close</b> button. As the result
|
||||||
|
it is possible to see how many names and materials are copied as well as
|
||||||
|
maximum number of names and materials available for copying. This information is
|
||||||
|
provided on the following message box:
|
||||||
|
|
||||||
|
\image html transfer_data2.png "Transfer Data Information"
|
||||||
|
|
||||||
|
<b>TUI Command:</b> <em>geompy.TransferData(ObjectFrom, ObjectTo, FindMethod),</em>
|
||||||
|
<br> where \em ObjectFrom is a data source object, \em ObjectTo is a
|
||||||
|
destination object and \em FindMethod is a same shape detection method with
|
||||||
|
default value \em GEOM.FSM_GetInPlace.
|
||||||
|
|
||||||
|
Our <b>TUI Scripts</b> provide you with useful example of the use of
|
||||||
|
\ref swig_TransferData "Transfer Data" functionality.
|
||||||
|
|
||||||
|
*/
|
@ -25,6 +25,8 @@ into water.</li>
|
|||||||
special case of \b Explode operation. </li>
|
special case of \b Explode operation. </li>
|
||||||
<li>\subpage shared_shapes_page "Get shared shapes" operation, a
|
<li>\subpage shared_shapes_page "Get shared shapes" operation, a
|
||||||
special case of \b Explode operation. </li>
|
special case of \b Explode operation. </li>
|
||||||
|
<li>\subpage transfer_data_page "Transfer Data" operation, which copies
|
||||||
|
non-topological data from one shape to another. </li>
|
||||||
|
|
||||||
|
|
||||||
<li>\subpage restore_presentation_parameters_page "Restore presentation parameters".
|
<li>\subpage restore_presentation_parameters_page "Restore presentation parameters".
|
||||||
|
@ -96,6 +96,9 @@
|
|||||||
\anchor swig_GetSharedShapes
|
\anchor swig_GetSharedShapes
|
||||||
\until "sharedEdge_"
|
\until "sharedEdge_"
|
||||||
|
|
||||||
|
\anchor swig_TransferData
|
||||||
|
\until subBlackWhite[1]
|
||||||
|
|
||||||
\anchor swig_CheckAndImprove
|
\anchor swig_CheckAndImprove
|
||||||
\until "blocksComp"
|
\until "blocksComp"
|
||||||
|
|
||||||
|
@ -115,7 +115,8 @@ module GEOM
|
|||||||
* \brief Kind of method to find inside one main shape some sub-shapes,
|
* \brief Kind of method to find inside one main shape some sub-shapes,
|
||||||
* corresponding to other given shape (its argument)
|
* corresponding to other given shape (its argument)
|
||||||
*
|
*
|
||||||
* Is used in functions GEOM_Gen.RestoreSubShapesO(), GEOM_Gen.RestoreSubShapesSO()
|
* Is used in functions GEOM_Gen.RestoreSubShapesO(), GEOM_Gen.RestoreSubShapesSO(),
|
||||||
|
* TransferNames()
|
||||||
*/
|
*/
|
||||||
enum find_shape_method
|
enum find_shape_method
|
||||||
{
|
{
|
||||||
@ -139,7 +140,10 @@ module GEOM
|
|||||||
/*! To be used only for multi-transformation result.
|
/*! To be used only for multi-transformation result.
|
||||||
* Only this method can be used after multi-transformation.
|
* Only this method can be used after multi-transformation.
|
||||||
*/
|
*/
|
||||||
FSM_MultiTransformed
|
FSM_MultiTransformed,
|
||||||
|
|
||||||
|
/*! Use old GetInPlace functionality. */
|
||||||
|
FSM_GetInPlace_Old
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -3976,7 +3980,41 @@ module GEOM
|
|||||||
* \return list of all texture IDs avaiable for the current study
|
* \return list of all texture IDs avaiable for the current study
|
||||||
*/
|
*/
|
||||||
ListOfLong GetAllTextures();
|
ListOfLong GetAllTextures();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Non-topological information transfer datum.
|
||||||
|
*/
|
||||||
|
struct TransferDatum
|
||||||
|
{
|
||||||
|
string myName;
|
||||||
|
long myNumber;
|
||||||
|
long myMaxNumber;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Sequence of non-topological information tranfer data.
|
||||||
|
*/
|
||||||
|
typedef sequence<TransferDatum> ListOfTransferDatum;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Transfer non-topological data from one object to another
|
||||||
|
* \param theObjectFrom the source object of non-topological data
|
||||||
|
* \param theObjectTo the destination object of non-topological data
|
||||||
|
* \param theFindMethod method to search sub-shapes of theObjectFrom
|
||||||
|
* in shape theObjectTo. Possible values are: GEOM::FSM_GetInPlace,
|
||||||
|
* GEOM::FSM_GetInPlaceByHistory and GEOM::FSM_GetInPlace_Old.
|
||||||
|
* Other values of GEOM::find_shape_method are not supported.
|
||||||
|
* \param theResult statistics of the operation. Output parameter. It
|
||||||
|
* represents a sequence of Transfer Datum. A datum has the type
|
||||||
|
* (string code), the total number of items of this type and
|
||||||
|
* the number of transfered items.
|
||||||
|
* \return true in case of success; otherwise false.
|
||||||
|
*/
|
||||||
|
boolean TransferData(in GEOM_Object theObjectFrom,
|
||||||
|
in GEOM_Object theObjectTo,
|
||||||
|
in find_shape_method theFindMethod,
|
||||||
|
out ListOfTransferDatum theResult);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// # GEOM_IKindOfShape:
|
// # GEOM_IKindOfShape:
|
||||||
|
@ -184,6 +184,7 @@ SET( _res_files
|
|||||||
torus.png
|
torus.png
|
||||||
torusdxyz.png
|
torusdxyz.png
|
||||||
toruspointvector.png
|
toruspointvector.png
|
||||||
|
transfer_data.png
|
||||||
translationDxyz.png
|
translationDxyz.png
|
||||||
translationPoints.png
|
translationPoints.png
|
||||||
translationVector.png
|
translationVector.png
|
||||||
|
BIN
resources/transfer_data.png
Normal file
BIN
resources/transfer_data.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 716 B |
@ -23,6 +23,8 @@
|
|||||||
INCLUDE_DIRECTORIES(
|
INCLUDE_DIRECTORIES(
|
||||||
${CAS_INCLUDE_DIRS}
|
${CAS_INCLUDE_DIRS}
|
||||||
${KERNEL_INCLUDE_DIRS}
|
${KERNEL_INCLUDE_DIRS}
|
||||||
|
${PROJECT_SOURCE_DIR}/src/GEOMUtils
|
||||||
|
${PROJECT_SOURCE_DIR}/src/GEOM
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}
|
${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -34,6 +36,7 @@ ADD_DEFINITIONS(
|
|||||||
# libraries to link to
|
# libraries to link to
|
||||||
SET(_link_LIBRARIES
|
SET(_link_LIBRARIES
|
||||||
${CAS_KERNEL} ${CAS_TKBool} ${CAS_TKBO} ${CAS_TKMesh}
|
${CAS_KERNEL} ${CAS_TKBool} ${CAS_TKBO} ${CAS_TKMesh}
|
||||||
|
GEOMbasic GEOMUtils
|
||||||
${KERNEL_SALOMELocalTrace}
|
${KERNEL_SALOMELocalTrace}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -60,6 +63,7 @@ SET(GEOMAlgo_HEADERS
|
|||||||
GEOMAlgo_FinderShapeOn2.hxx
|
GEOMAlgo_FinderShapeOn2.hxx
|
||||||
GEOMAlgo_FinderShapeOnQuad.hxx
|
GEOMAlgo_FinderShapeOnQuad.hxx
|
||||||
GEOMAlgo_GetInPlace.hxx
|
GEOMAlgo_GetInPlace.hxx
|
||||||
|
GEOMAlgo_GetInPlaceAPI.hxx
|
||||||
GEOMAlgo_GlueAnalyser.hxx
|
GEOMAlgo_GlueAnalyser.hxx
|
||||||
GEOMAlgo_GlueDetector.hxx
|
GEOMAlgo_GlueDetector.hxx
|
||||||
GEOMAlgo_Gluer.hxx
|
GEOMAlgo_Gluer.hxx
|
||||||
@ -123,6 +127,7 @@ SET(GEOMAlgo_SOURCES
|
|||||||
GEOMAlgo_GetInPlace_1.cxx
|
GEOMAlgo_GetInPlace_1.cxx
|
||||||
GEOMAlgo_GetInPlace_2.cxx
|
GEOMAlgo_GetInPlace_2.cxx
|
||||||
GEOMAlgo_GetInPlace_3.cxx
|
GEOMAlgo_GetInPlace_3.cxx
|
||||||
|
GEOMAlgo_GetInPlaceAPI.cxx
|
||||||
GEOMAlgo_GlueAnalyser.cxx
|
GEOMAlgo_GlueAnalyser.cxx
|
||||||
GEOMAlgo_GlueDetector.cxx
|
GEOMAlgo_GlueDetector.cxx
|
||||||
GEOMAlgo_Gluer.cxx
|
GEOMAlgo_Gluer.cxx
|
||||||
@ -142,7 +147,7 @@ SET(GEOMAlgo_SOURCES
|
|||||||
GEOMAlgo_ShapeInfoFiller.cxx
|
GEOMAlgo_ShapeInfoFiller.cxx
|
||||||
GEOMAlgo_ShapeInfoFiller_1.cxx
|
GEOMAlgo_ShapeInfoFiller_1.cxx
|
||||||
GEOMAlgo_ShapeSolid.cxx
|
GEOMAlgo_ShapeSolid.cxx
|
||||||
GEOMAlgo_ShellSolid.cxx
|
GEOMAlgo_ShellSolid.cxx
|
||||||
GEOMAlgo_SolidSolid.cxx
|
GEOMAlgo_SolidSolid.cxx
|
||||||
GEOMAlgo_Splitter.cxx
|
GEOMAlgo_Splitter.cxx
|
||||||
GEOMAlgo_StateCollector.cxx
|
GEOMAlgo_StateCollector.cxx
|
||||||
|
@ -54,6 +54,8 @@ GEOMAlgo_GetInPlace.cxx
|
|||||||
GEOMAlgo_GetInPlace_1.cxx
|
GEOMAlgo_GetInPlace_1.cxx
|
||||||
GEOMAlgo_GetInPlace_2.cxx
|
GEOMAlgo_GetInPlace_2.cxx
|
||||||
GEOMAlgo_GetInPlace_3.cxx
|
GEOMAlgo_GetInPlace_3.cxx
|
||||||
|
GEOMAlgo_GetInPlaceAPI.hxx
|
||||||
|
GEOMAlgo_GetInPlaceAPI.cxx
|
||||||
GEOMAlgo_Splitter.hxx
|
GEOMAlgo_Splitter.hxx
|
||||||
GEOMAlgo_Splitter.cxx
|
GEOMAlgo_Splitter.cxx
|
||||||
GEOMAlgo_ShapeInfoFiller.hxx
|
GEOMAlgo_ShapeInfoFiller.hxx
|
||||||
|
450
src/GEOMAlgo/GEOMAlgo_GetInPlaceAPI.cxx
Normal file
450
src/GEOMAlgo/GEOMAlgo_GetInPlaceAPI.cxx
Normal file
@ -0,0 +1,450 @@
|
|||||||
|
// Copyright (C) 2007-2014 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, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// 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: GEOMAlgo_GetInPlaceAPI.cxx
|
||||||
|
// Created:
|
||||||
|
// Author: Sergey KHROMOV
|
||||||
|
|
||||||
|
|
||||||
|
#include <GEOMAlgo_GetInPlaceAPI.hxx>
|
||||||
|
#include <GEOMAlgo_GetInPlace.hxx>
|
||||||
|
#include <GEOM_Function.hxx>
|
||||||
|
#include <GEOM_Object.hxx>
|
||||||
|
#include <GEOMUtils.hxx>
|
||||||
|
|
||||||
|
#include <Bnd_Box.hxx>
|
||||||
|
#include <BRepAdaptor_Surface.hxx>
|
||||||
|
#include <BRepBndLib.hxx>
|
||||||
|
#include <BRepBuilderAPI_MakeVertex.hxx>
|
||||||
|
#include <BRepExtrema_DistShapeShape.hxx>
|
||||||
|
#include <BRepGProp.hxx>
|
||||||
|
#include <BRep_Tool.hxx>
|
||||||
|
#include <Geom2d_Curve.hxx>
|
||||||
|
#include <GProp_GProps.hxx>
|
||||||
|
#include <gp_Pnt.hxx>
|
||||||
|
#include <Precision.hxx>
|
||||||
|
#include <TDataStd_IntegerArray.hxx>
|
||||||
|
#include <TopExp.hxx>
|
||||||
|
#include <TopExp_Explorer.hxx>
|
||||||
|
#include <TopoDS.hxx>
|
||||||
|
#include <TopoDS_Vertex.hxx>
|
||||||
|
#include <TopTools_MapOfShape.hxx>
|
||||||
|
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : GetInPlace
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Boolean GEOMAlgo_GetInPlaceAPI::GetInPlace
|
||||||
|
(const TopoDS_Shape &theWhere,
|
||||||
|
const TopoDS_Shape &theWhat,
|
||||||
|
GEOMAlgo_GetInPlace &theGIP)
|
||||||
|
{
|
||||||
|
if (theWhere.IsNull() || theWhat.IsNull()) {
|
||||||
|
return Standard_False;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compute confusion tolerance.
|
||||||
|
Standard_Real aTolConf = Precision::Confusion();
|
||||||
|
Standard_Integer i;
|
||||||
|
|
||||||
|
for (i = 0; i < 2; ++i) {
|
||||||
|
TopExp_Explorer anExp(i == 0 ? theWhere : theWhat, TopAbs_VERTEX);
|
||||||
|
|
||||||
|
for (; anExp.More(); anExp.Next()) {
|
||||||
|
const TopoDS_Vertex aVtx = TopoDS::Vertex(anExp.Current());
|
||||||
|
const Standard_Real aTolVtx = BRep_Tool::Tolerance(aVtx);
|
||||||
|
|
||||||
|
if (aTolVtx > aTolConf) {
|
||||||
|
aTolConf = aTolVtx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compute mass tolerance.
|
||||||
|
Bnd_Box aBoundingBox;
|
||||||
|
Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
|
||||||
|
Standard_Real aMassTol;
|
||||||
|
|
||||||
|
BRepBndLib::Add(theWhere, aBoundingBox);
|
||||||
|
BRepBndLib::Add(theWhat, aBoundingBox);
|
||||||
|
aBoundingBox.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
|
||||||
|
aMassTol = Max(aXmax - aXmin, aYmax - aYmin);
|
||||||
|
aMassTol = Max(aMassTol, aZmax - aZmin);
|
||||||
|
aMassTol *= aTolConf;
|
||||||
|
|
||||||
|
// Searching for the sub-shapes inside the ShapeWhere shape
|
||||||
|
theGIP.SetTolerance(aTolConf);
|
||||||
|
theGIP.SetTolMass(aMassTol);
|
||||||
|
theGIP.SetTolCG(aTolConf);
|
||||||
|
|
||||||
|
theGIP.SetArgument(theWhat);
|
||||||
|
theGIP.SetShapeWhere(theWhere);
|
||||||
|
|
||||||
|
theGIP.Perform();
|
||||||
|
|
||||||
|
int iErr = theGIP.ErrorStatus();
|
||||||
|
|
||||||
|
if (iErr) {
|
||||||
|
return Standard_False;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Standard_True;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : GetInPlaceOld
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Integer GEOMAlgo_GetInPlaceAPI::GetInPlaceOld
|
||||||
|
(const TopoDS_Shape &theWhere,
|
||||||
|
const TopoDS_Shape &theWhat,
|
||||||
|
TopTools_ListOfShape &theShapesInPlace)
|
||||||
|
{
|
||||||
|
theShapesInPlace.Clear();
|
||||||
|
|
||||||
|
if (theWhere.IsNull() || theWhat.IsNull()) {
|
||||||
|
// Error: aWhere and aWhat TopoDS_Shape are Null.
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
TopoDS_Shape aPntShape;
|
||||||
|
TopoDS_Vertex aVertex;
|
||||||
|
bool isFound = false;
|
||||||
|
TopAbs_ShapeEnum iType = TopAbs_SOLID;
|
||||||
|
//Standard_Real aWhat_Mass = 0., aWhere_Mass = 0.;
|
||||||
|
Standard_Real tab_aWhat[4], tab_aWhere[4];
|
||||||
|
Standard_Real dl_l = 1e-3;
|
||||||
|
Standard_Real min_l, Tol_0D, Tol_1D, Tol_2D, Tol_3D, Tol_Mass;
|
||||||
|
Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
|
||||||
|
Bnd_Box BoundingBox;
|
||||||
|
gp_Pnt aPnt, aPnt_aWhat, tab_Pnt[2];
|
||||||
|
GProp_GProps aProps;
|
||||||
|
|
||||||
|
iType = GEOMUtils::GetTypeOfSimplePart(theWhat);
|
||||||
|
if (iType == TopAbs_SHAPE) {
|
||||||
|
// Error: An attempt to extract a shape of not supported type.
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
TopExp_Explorer Exp_aWhat ( theWhat, iType );
|
||||||
|
TopExp_Explorer Exp_aWhere ( theWhere, iType );
|
||||||
|
TopExp_Explorer Exp_Edge ( theWhere, TopAbs_EDGE );
|
||||||
|
|
||||||
|
// Find the shortest edge in theShapeWhere shape
|
||||||
|
BRepBndLib::Add(theWhere, BoundingBox);
|
||||||
|
BoundingBox.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
|
||||||
|
min_l = fabs(aXmax - aXmin);
|
||||||
|
if( min_l < fabs(aYmax - aYmin) ) min_l = fabs(aYmax - aYmin);
|
||||||
|
if( min_l < fabs(aZmax - aZmin) ) min_l = fabs(aZmax - aZmin);
|
||||||
|
min_l /= dl_l;
|
||||||
|
// Mantis issue 0020908 BEGIN
|
||||||
|
if (!Exp_Edge.More()) {
|
||||||
|
min_l = Precision::Confusion();
|
||||||
|
}
|
||||||
|
// Mantis issue 0020908 END
|
||||||
|
for ( Standard_Integer nbEdge = 0; Exp_Edge.More(); Exp_Edge.Next(), nbEdge++ ) {
|
||||||
|
TopExp_Explorer Exp_Vertex( Exp_Edge.Current(), TopAbs_VERTEX);
|
||||||
|
for ( Standard_Integer nbVertex = 0; Exp_Vertex.More(); Exp_Vertex.Next(), nbVertex++ ) {
|
||||||
|
aPnt = BRep_Tool::Pnt( TopoDS::Vertex( Exp_Vertex.Current() ) );
|
||||||
|
tab_Pnt[nbVertex] = aPnt;
|
||||||
|
}
|
||||||
|
if ( ! tab_Pnt[0].IsEqual(tab_Pnt[1], dl_l) ) {
|
||||||
|
BRepGProp::LinearProperties(Exp_Edge.Current(), aProps);
|
||||||
|
if ( aProps.Mass() < min_l ) min_l = aProps.Mass();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compute tolerances
|
||||||
|
Tol_0D = dl_l;
|
||||||
|
Tol_1D = dl_l * min_l;
|
||||||
|
Tol_2D = dl_l * ( min_l * min_l) * ( 2. + dl_l);
|
||||||
|
Tol_3D = dl_l * ( min_l * min_l * min_l ) * ( 3. + (3 * dl_l) + (dl_l * dl_l) );
|
||||||
|
|
||||||
|
if (Tol_0D < Precision::Confusion()) Tol_0D = Precision::Confusion();
|
||||||
|
if (Tol_1D < Precision::Confusion()) Tol_1D = Precision::Confusion();
|
||||||
|
if (Tol_2D < Precision::Confusion()) Tol_2D = Precision::Confusion();
|
||||||
|
if (Tol_3D < Precision::Confusion()) Tol_3D = Precision::Confusion();
|
||||||
|
|
||||||
|
Tol_Mass = Tol_3D;
|
||||||
|
if ( iType == TopAbs_VERTEX ) Tol_Mass = Tol_0D;
|
||||||
|
else if ( iType == TopAbs_EDGE ) Tol_Mass = Tol_1D;
|
||||||
|
else if ( iType == TopAbs_FACE ) Tol_Mass = Tol_2D;
|
||||||
|
|
||||||
|
// Searching for the sub-shapes inside the ShapeWhere shape
|
||||||
|
TopTools_MapOfShape map_aWhere;
|
||||||
|
for ( Exp_aWhere.ReInit(); Exp_aWhere.More(); Exp_aWhere.Next() ) {
|
||||||
|
if (!map_aWhere.Add(Exp_aWhere.Current()))
|
||||||
|
continue; // skip repeated shape to avoid mass addition
|
||||||
|
GetShapeProperties( Exp_aWhere.Current(), tab_aWhere, aPnt );
|
||||||
|
for ( Exp_aWhat.ReInit(); Exp_aWhat.More(); Exp_aWhat.Next() ) {
|
||||||
|
GetShapeProperties( Exp_aWhat.Current(), tab_aWhat, aPnt_aWhat );
|
||||||
|
if ( fabs(tab_aWhat[3] - tab_aWhere[3]) <= Tol_Mass && aPnt_aWhat.Distance(aPnt) <= Tol_1D )
|
||||||
|
isFound = true;
|
||||||
|
else {
|
||||||
|
if ( (tab_aWhat[3] - tab_aWhere[3]) > Tol_Mass ) {
|
||||||
|
aPntShape = BRepBuilderAPI_MakeVertex( aPnt ).Shape();
|
||||||
|
aVertex = TopoDS::Vertex( aPntShape );
|
||||||
|
BRepExtrema_DistShapeShape aWhereDistance ( aVertex, Exp_aWhere.Current() );
|
||||||
|
BRepExtrema_DistShapeShape aWhatDistance ( aVertex, Exp_aWhat.Current() );
|
||||||
|
if ( aWhereDistance.IsDone() && aWhatDistance.IsDone() &&
|
||||||
|
fabs(aWhereDistance.Value() - aWhatDistance.Value()) <= Tol_1D )
|
||||||
|
{
|
||||||
|
// 0020162: "EDF 961 GEOM : Getinplace is getting additionnal orthogonal faces"
|
||||||
|
// aVertex must be projected to the same point on Where and on What
|
||||||
|
gp_Pnt pOnWhat = aWhatDistance.PointOnShape2(1);
|
||||||
|
gp_Pnt pOnWhere = aWhereDistance.PointOnShape2(1);
|
||||||
|
isFound = ( pOnWhat.Distance(pOnWhere) <= Tol_1D );
|
||||||
|
if ( isFound && iType == TopAbs_FACE )
|
||||||
|
{
|
||||||
|
// check normals at pOnWhat and pOnWhere
|
||||||
|
const double angleTol = M_PI/180.;
|
||||||
|
gp_Vec normToWhat = GetNormal( TopoDS::Face(Exp_aWhat.Current()), aWhatDistance);
|
||||||
|
gp_Vec normToWhere = GetNormal( TopoDS::Face(Exp_aWhere.Current()), aWhereDistance);
|
||||||
|
if ( normToWhat * normToWhere < 0 )
|
||||||
|
normToWhat.Reverse();
|
||||||
|
isFound = ( normToWhat.Angle( normToWhere ) < angleTol );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( isFound ) {
|
||||||
|
theShapesInPlace.Append(Exp_aWhere.Current());
|
||||||
|
//aWhere_Mass += tab_aWhere[3];
|
||||||
|
isFound = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (theShapesInPlace.Extent() == 0) {
|
||||||
|
// Not found any Results
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : GetNormal
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
gp_Vec GEOMAlgo_GetInPlaceAPI::GetNormal
|
||||||
|
(const TopoDS_Face &theFace,
|
||||||
|
const BRepExtrema_DistShapeShape &theExtrema)
|
||||||
|
{
|
||||||
|
gp_Vec defaultNorm(1,0,0); // to have same normals on different faces
|
||||||
|
try {
|
||||||
|
// get UV at extrema point
|
||||||
|
Standard_Real u,v, f,l;
|
||||||
|
switch ( theExtrema.SupportTypeShape2(1) ) {
|
||||||
|
case BRepExtrema_IsInFace: {
|
||||||
|
theExtrema.ParOnFaceS2(1, u, v );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case BRepExtrema_IsOnEdge: {
|
||||||
|
TopoDS_Edge edge = TopoDS::Edge( theExtrema.SupportOnShape2(1));
|
||||||
|
Handle(Geom2d_Curve) pcurve =
|
||||||
|
BRep_Tool::CurveOnSurface(edge, theFace, f,l);
|
||||||
|
|
||||||
|
theExtrema.ParOnEdgeS2( 1, u );
|
||||||
|
gp_Pnt2d uv = pcurve->Value( u );
|
||||||
|
u = uv.Coord(1);
|
||||||
|
v = uv.Coord(2);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case BRepExtrema_IsVertex: return defaultNorm;
|
||||||
|
}
|
||||||
|
// get derivatives
|
||||||
|
BRepAdaptor_Surface surface( theFace, false );
|
||||||
|
gp_Vec du, dv; gp_Pnt p;
|
||||||
|
surface.D1( u, v, p, du, dv );
|
||||||
|
|
||||||
|
return du ^ dv;
|
||||||
|
|
||||||
|
} catch (Standard_Failure ) {
|
||||||
|
}
|
||||||
|
return defaultNorm;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : GetShapeProperties
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_GetInPlaceAPI::GetShapeProperties(const TopoDS_Shape &theShape,
|
||||||
|
Standard_Real theTab[],
|
||||||
|
gp_Pnt &theVertex)
|
||||||
|
{
|
||||||
|
GProp_GProps aProps;
|
||||||
|
gp_Pnt aCenterMass;
|
||||||
|
Standard_Real aShapeSize;
|
||||||
|
|
||||||
|
if (theShape.ShapeType() == TopAbs_VERTEX) {
|
||||||
|
aCenterMass = BRep_Tool::Pnt(TopoDS::Vertex(theShape));
|
||||||
|
} else if (theShape.ShapeType() == TopAbs_EDGE) {
|
||||||
|
BRepGProp::LinearProperties(theShape, aProps);
|
||||||
|
} else if (theShape.ShapeType() == TopAbs_FACE) {
|
||||||
|
BRepGProp::SurfaceProperties(theShape, aProps);
|
||||||
|
} else {
|
||||||
|
BRepGProp::VolumeProperties(theShape, aProps);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (theShape.ShapeType() == TopAbs_VERTEX) {
|
||||||
|
aShapeSize = 1;
|
||||||
|
} else {
|
||||||
|
aCenterMass = aProps.CentreOfMass();
|
||||||
|
aShapeSize = aProps.Mass();
|
||||||
|
}
|
||||||
|
|
||||||
|
theVertex = aCenterMass;
|
||||||
|
theTab[0] = theVertex.X();
|
||||||
|
theTab[1] = theVertex.Y();
|
||||||
|
theTab[2] = theVertex.Z();
|
||||||
|
theTab[3] = aShapeSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : GetInPlaceByHistory
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Boolean GEOMAlgo_GetInPlaceAPI::GetInPlaceByHistory
|
||||||
|
(const Handle(GEOM_Function) &theWhereFunction,
|
||||||
|
const TopTools_IndexedMapOfShape &theWhereIndices,
|
||||||
|
const TopoDS_Shape &theWhat,
|
||||||
|
TopTools_ListOfShape &theShapesInPlace)
|
||||||
|
{
|
||||||
|
if (theWhereFunction.IsNull() || theWhat.IsNull())
|
||||||
|
return Standard_False;
|
||||||
|
|
||||||
|
if (theWhereIndices.Contains(theWhat)) {
|
||||||
|
// entity was not changed by the operation
|
||||||
|
theShapesInPlace.Append(theWhat);
|
||||||
|
|
||||||
|
return Standard_True;
|
||||||
|
}
|
||||||
|
|
||||||
|
// try to find in history
|
||||||
|
TDF_Label aHistoryLabel = theWhereFunction->GetHistoryEntry(Standard_False);
|
||||||
|
|
||||||
|
// search in history for all argument shapes
|
||||||
|
Standard_Boolean isFound = Standard_False;
|
||||||
|
Standard_Boolean isGood = Standard_False;
|
||||||
|
|
||||||
|
TDF_LabelSequence aLabelSeq;
|
||||||
|
theWhereFunction->GetDependency(aLabelSeq);
|
||||||
|
Standard_Integer nbArg = aLabelSeq.Length();
|
||||||
|
|
||||||
|
for (Standard_Integer iarg = 1; iarg <= nbArg && !isFound; iarg++) {
|
||||||
|
|
||||||
|
TDF_Label anArgumentRefLabel = aLabelSeq.Value(iarg);
|
||||||
|
|
||||||
|
Handle(GEOM_Object) anArgumentObject = GEOM_Object::GetReferencedObject(anArgumentRefLabel);
|
||||||
|
TopoDS_Shape anArgumentShape = anArgumentObject->GetValue();
|
||||||
|
|
||||||
|
TopTools_IndexedMapOfShape anArgumentIndices;
|
||||||
|
TopExp::MapShapes(anArgumentShape, anArgumentIndices);
|
||||||
|
|
||||||
|
if (anArgumentIndices.Contains(theWhat)) {
|
||||||
|
isFound = Standard_True;
|
||||||
|
Standard_Integer aWhatIndex = anArgumentIndices.FindIndex(theWhat);
|
||||||
|
|
||||||
|
// Find corresponding label in history
|
||||||
|
TDF_Label anArgumentHistoryLabel =
|
||||||
|
theWhereFunction->GetArgumentHistoryEntry(anArgumentRefLabel, Standard_False);
|
||||||
|
if (anArgumentHistoryLabel.IsNull()) {
|
||||||
|
// Lost History of operation argument. Possibly, all its entities was removed.
|
||||||
|
isGood = Standard_True;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
TDF_Label aWhatHistoryLabel = anArgumentHistoryLabel.FindChild(aWhatIndex, Standard_False);
|
||||||
|
|
||||||
|
if (aWhatHistoryLabel.IsNull()) {
|
||||||
|
// Removed entity ? Compound ? Compsolid ? Shell ? Wire
|
||||||
|
isGood = Standard_False;
|
||||||
|
} else {
|
||||||
|
Handle(TDataStd_IntegerArray) anIntegerArray;
|
||||||
|
if (!aWhatHistoryLabel.FindAttribute(TDataStd_IntegerArray::GetID(), anIntegerArray)) {
|
||||||
|
//Error: Empty modifications history for the sought shape.
|
||||||
|
isGood = Standard_False;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
isGood = Standard_True;
|
||||||
|
Standard_Integer imod, aModifLen = anIntegerArray->Array()->Length();
|
||||||
|
for (imod = 1; imod <= aModifLen; imod++) {
|
||||||
|
const Standard_Integer anIndex =
|
||||||
|
anIntegerArray->Array()->Value(imod);
|
||||||
|
|
||||||
|
theShapesInPlace.Append(theWhereIndices.FindKey(anIndex));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
isFound = isGood;
|
||||||
|
|
||||||
|
if (!isFound) {
|
||||||
|
// try compound/compsolid/shell/wire element by element
|
||||||
|
Standard_Boolean isFoundAny = Standard_False;
|
||||||
|
TopTools_MapOfShape mapShape;
|
||||||
|
|
||||||
|
if (theWhat.ShapeType() == TopAbs_COMPOUND ||
|
||||||
|
theWhat.ShapeType() == TopAbs_COMPSOLID) {
|
||||||
|
// recursive processing of compound/compsolid
|
||||||
|
TopoDS_Iterator anIt (theWhat, Standard_True, Standard_True);
|
||||||
|
for (; anIt.More(); anIt.Next()) {
|
||||||
|
if (mapShape.Add(anIt.Value())) {
|
||||||
|
TopoDS_Shape curWhat = anIt.Value();
|
||||||
|
isFoundAny = GetInPlaceByHistory(theWhereFunction, theWhereIndices, curWhat, theShapesInPlace);
|
||||||
|
if (isFoundAny) isFound = Standard_True;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (theWhat.ShapeType() == TopAbs_SHELL) {
|
||||||
|
// try to replace a shell by its faces images
|
||||||
|
TopExp_Explorer anExp (theWhat, TopAbs_FACE);
|
||||||
|
for (; anExp.More(); anExp.Next()) {
|
||||||
|
if (mapShape.Add(anExp.Current())) {
|
||||||
|
TopoDS_Shape curWhat = anExp.Current();
|
||||||
|
isFoundAny = GetInPlaceByHistory(theWhereFunction, theWhereIndices, curWhat, theShapesInPlace);
|
||||||
|
if (isFoundAny) isFound = Standard_True;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (theWhat.ShapeType() == TopAbs_WIRE) {
|
||||||
|
// try to replace a wire by its edges images
|
||||||
|
TopExp_Explorer anExp (theWhat, TopAbs_EDGE);
|
||||||
|
for (; anExp.More(); anExp.Next()) {
|
||||||
|
if (mapShape.Add(anExp.Current())) {
|
||||||
|
TopoDS_Shape curWhat = anExp.Current();
|
||||||
|
isFoundAny = GetInPlaceByHistory(theWhereFunction, theWhereIndices, curWhat, theShapesInPlace);
|
||||||
|
if (isFoundAny) isFound = Standard_True;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Removed entity
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return isFound;
|
||||||
|
}
|
111
src/GEOMAlgo/GEOMAlgo_GetInPlaceAPI.hxx
Normal file
111
src/GEOMAlgo/GEOMAlgo_GetInPlaceAPI.hxx
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
// Copyright (C) 2007-2014 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, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// 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: GEOMAlgo_GetInPlaceAPI.hxx
|
||||||
|
// Created:
|
||||||
|
// Author: Sergey KHROMOV
|
||||||
|
|
||||||
|
#ifndef _GEOMAlgo_GetInPlaceAPI_HeaderFile
|
||||||
|
#define _GEOMAlgo_GetInPlaceAPI_HeaderFile
|
||||||
|
|
||||||
|
|
||||||
|
#include <gp_Vec.hxx>
|
||||||
|
|
||||||
|
class GEOMAlgo_GetInPlace;
|
||||||
|
class Handle_GEOM_Function;
|
||||||
|
class BRepExtrema_DistShapeShape;
|
||||||
|
class TopoDS_Face;
|
||||||
|
class TopoDS_Shape;
|
||||||
|
class TopTools_IndexedMapOfShape;
|
||||||
|
class TopTools_ListOfShape;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is an API class for all GetInPlace algorithm.
|
||||||
|
* It facilitates using different GetInPlace algorithms:
|
||||||
|
* a new one(GEOMAlgo_GetInPlace), an old one and
|
||||||
|
* GetInPlaceByHistory.
|
||||||
|
*/
|
||||||
|
class GEOMAlgo_GetInPlaceAPI
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief New GetInPlace method implementation.
|
||||||
|
* Initializes the GEOMAlgo_GetInPlace object with correct parameters and
|
||||||
|
* performs computation (calls theGIP's method Perform. Returns
|
||||||
|
* Standard_True in face of success; Standard_False otherwise.
|
||||||
|
*/
|
||||||
|
Standard_EXPORT static Standard_Boolean GetInPlace
|
||||||
|
(const TopoDS_Shape &theWhere,
|
||||||
|
const TopoDS_Shape &theWhat,
|
||||||
|
GEOMAlgo_GetInPlace &theGIP);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Old implementation of GetInPlace algoritm.
|
||||||
|
* This method searches among sub shapes of the shape theWhere parts that are
|
||||||
|
* coincident with the shape theWhat. The result list of shape is returned as
|
||||||
|
* an output parameter. It returns the error code with the following possible
|
||||||
|
* values:
|
||||||
|
* 0 - Success;
|
||||||
|
* 1 - theWhere and/or theWhat TopoDS_Shape are Null;
|
||||||
|
* 2 - An attempt to extract a shape of not supported type;
|
||||||
|
* 3 - Not found any Results.
|
||||||
|
*/
|
||||||
|
Standard_EXPORT static Standard_Integer GetInPlaceOld
|
||||||
|
(const TopoDS_Shape &theWhere,
|
||||||
|
const TopoDS_Shape &theWhat,
|
||||||
|
TopTools_ListOfShape &theShapesInPlace);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief GetInPlaceByHistory method implementation.
|
||||||
|
* Returns Standard_True if something is found. Warning: theShapesInPlace
|
||||||
|
* list is not cleared at first.
|
||||||
|
*/
|
||||||
|
Standard_EXPORT static Standard_Boolean GetInPlaceByHistory
|
||||||
|
(const Handle_GEOM_Function &theWhereFunction,
|
||||||
|
const TopTools_IndexedMapOfShape &theWhereIndices,
|
||||||
|
const TopoDS_Shape &theWhat,
|
||||||
|
TopTools_ListOfShape &theShapesInPlace);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Return normal to face at extrema point
|
||||||
|
*/
|
||||||
|
static gp_Vec GetNormal(const TopoDS_Face &theFace,
|
||||||
|
const BRepExtrema_DistShapeShape &theExtrema);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Return the global properties of the shape: center of mass and
|
||||||
|
* a size (length, area or volume depending on the shape type).
|
||||||
|
*/
|
||||||
|
static void GetShapeProperties(const TopoDS_Shape &theShape,
|
||||||
|
Standard_Real theTab[],
|
||||||
|
gp_Pnt &theVertex);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
@ -1351,6 +1351,10 @@
|
|||||||
<source>ICO_GET_SHARED_SHAPES</source>
|
<source>ICO_GET_SHARED_SHAPES</source>
|
||||||
<translation>shared_shapes.png</translation>
|
<translation>shared_shapes.png</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>ICO_TRANSFER_DATA</source>
|
||||||
|
<translation>transfer_data.png</translation>
|
||||||
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>ICON_DLG_POINT_FACE</source>
|
<source>ICON_DLG_POINT_FACE</source>
|
||||||
<translation>pointonface.png</translation>
|
<translation>pointonface.png</translation>
|
||||||
@ -1363,6 +1367,10 @@
|
|||||||
<source>ICON_DLG_SHARED_SHAPES</source>
|
<source>ICON_DLG_SHARED_SHAPES</source>
|
||||||
<translation>shared_shapes.png</translation>
|
<translation>shared_shapes.png</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>ICON_DLG_TRANSFER_DATA</source>
|
||||||
|
<translation>transfer_data.png</translation>
|
||||||
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>ICON_DLG_SCALE_ALONG_AXES</source>
|
<source>ICON_DLG_SCALE_ALONG_AXES</source>
|
||||||
<translation>scale_along_axes.png</translation>
|
<translation>scale_along_axes.png</translation>
|
||||||
|
@ -5052,6 +5052,18 @@ Please, select face, shell or solid and try again</translation>
|
|||||||
<source>STB_GET_SHARED_SHAPES</source>
|
<source>STB_GET_SHARED_SHAPES</source>
|
||||||
<translation>Get shared shapes</translation>
|
<translation>Get shared shapes</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>TOP_TRANSFER_DATA</source>
|
||||||
|
<translation>Transfer Data</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>MEN_TRANSFER_DATA</source>
|
||||||
|
<translation>Transfer Data</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>STB_TRANSFER_DATA</source>
|
||||||
|
<translation>Transfer Data</translation>
|
||||||
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>TOP_EXTENSION</source>
|
<source>TOP_EXTENSION</source>
|
||||||
<translation>Extend Edge or Face</translation>
|
<translation>Extend Edge or Face</translation>
|
||||||
@ -7184,4 +7196,59 @@ Do you want to create new material?</translation>
|
|||||||
<translation>SurfaceFromFace</translation>
|
<translation>SurfaceFromFace</translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>OperationGUI_TransferDataDlg</name>
|
||||||
|
<message>
|
||||||
|
<source>GEOM_TRANSFER_DATA_TITLE</source>
|
||||||
|
<translation>Transfer Data</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>GEOM_TRANSFER_DATA</source>
|
||||||
|
<translation>Transfer Data</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>GEOM_TRANSFER_DATA_FROM</source>
|
||||||
|
<translation>Source Shape</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>GEOM_TRANSFER_DATA_TO</source>
|
||||||
|
<translation>Destination Shape</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>GEOM_TRANSFER_DATA_METHOD</source>
|
||||||
|
<translation>Type of Detection Operation</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>GEOM_TD_METHOD_GETINPLACE</source>
|
||||||
|
<translation>Get In Place</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>GEOM_TD_METHOD_GETINPLACE_OLD</source>
|
||||||
|
<translation>Get In Place (old)</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>GEOM_TD_METHOD_GETINPLACE_HISTORY</source>
|
||||||
|
<translation>Get In Place By History</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>GEOM_TRANSFER_DATA_INFO</source>
|
||||||
|
<translation>Transfer Data: Information</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>GEOM_TRANSFER_DATA_NOT_COPIED</source>
|
||||||
|
<translation>There is nothing to be copied.</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>GEOM_TRANSFER_DATA_COPIED</source>
|
||||||
|
<translation>The following data are copied:</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>GEOM_TRANSFER_DATA_NAMES</source>
|
||||||
|
<translation>Names: %1 of %2</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>GEOM_TRANSFER_DATA_MATERIALS</source>
|
||||||
|
<translation>Materials: %1 of %2</translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
</TS>
|
</TS>
|
||||||
|
@ -602,6 +602,7 @@ void GeometryGUI::OnGUIEvent( int id, const QVariant& theParam )
|
|||||||
case GEOMOp::OpSharedShapes: // MENU OPERATION - GET SHARED SHAPES
|
case GEOMOp::OpSharedShapes: // MENU OPERATION - GET SHARED SHAPES
|
||||||
case GEOMOp::OpExtrudedBoss: // MENU OPERATION - EXTRUDED BOSS
|
case GEOMOp::OpExtrudedBoss: // MENU OPERATION - EXTRUDED BOSS
|
||||||
case GEOMOp::OpExtrudedCut: // MENU OPERATION - EXTRUDED CUT
|
case GEOMOp::OpExtrudedCut: // MENU OPERATION - EXTRUDED CUT
|
||||||
|
case GEOMOp::OpTransferData: // MENU OPERATION - TRANSFER DATA
|
||||||
libName = "OperationGUI";
|
libName = "OperationGUI";
|
||||||
break;
|
break;
|
||||||
case GEOMOp::OpSewing: // MENU REPAIR - SEWING
|
case GEOMOp::OpSewing: // MENU REPAIR - SEWING
|
||||||
@ -971,6 +972,7 @@ void GeometryGUI::initialize( CAM_Application* app )
|
|||||||
//createGeomAction( GEOMOp::OpClipping, "CLIPPING" );
|
//createGeomAction( GEOMOp::OpClipping, "CLIPPING" );
|
||||||
createGeomAction( GEOMOp::OpShapesOnShape, "GET_SHAPES_ON_SHAPE" );
|
createGeomAction( GEOMOp::OpShapesOnShape, "GET_SHAPES_ON_SHAPE" );
|
||||||
createGeomAction( GEOMOp::OpSharedShapes, "GET_SHARED_SHAPES" );
|
createGeomAction( GEOMOp::OpSharedShapes, "GET_SHARED_SHAPES" );
|
||||||
|
createGeomAction( GEOMOp::OpTransferData, "TRANSFER_DATA" );
|
||||||
createGeomAction( GEOMOp::OpExtrudedCut, "EXTRUDED_CUT" );
|
createGeomAction( GEOMOp::OpExtrudedCut, "EXTRUDED_CUT" );
|
||||||
createGeomAction( GEOMOp::OpExtrudedBoss, "EXTRUDED_BOSS" );
|
createGeomAction( GEOMOp::OpExtrudedBoss, "EXTRUDED_BOSS" );
|
||||||
createGeomAction( GEOMOp::OpFillet1d, "FILLET_1D" );
|
createGeomAction( GEOMOp::OpFillet1d, "FILLET_1D" );
|
||||||
@ -1214,6 +1216,7 @@ void GeometryGUI::initialize( CAM_Application* app )
|
|||||||
createMenu( GEOMOp::OpArchimede, operId, -1 );
|
createMenu( GEOMOp::OpArchimede, operId, -1 );
|
||||||
createMenu( GEOMOp::OpShapesOnShape, operId, -1 );
|
createMenu( GEOMOp::OpShapesOnShape, operId, -1 );
|
||||||
createMenu( GEOMOp::OpSharedShapes, operId, -1 );
|
createMenu( GEOMOp::OpSharedShapes, operId, -1 );
|
||||||
|
createMenu( GEOMOp::OpTransferData, operId, -1 );
|
||||||
|
|
||||||
createMenu( separator(), operId, -1 );
|
createMenu( separator(), operId, -1 );
|
||||||
|
|
||||||
@ -1379,6 +1382,7 @@ void GeometryGUI::initialize( CAM_Application* app )
|
|||||||
createTool( GEOMOp::OpArchimede, operTbId );
|
createTool( GEOMOp::OpArchimede, operTbId );
|
||||||
createTool( GEOMOp::OpShapesOnShape, operTbId );
|
createTool( GEOMOp::OpShapesOnShape, operTbId );
|
||||||
createTool( GEOMOp::OpSharedShapes, operTbId );
|
createTool( GEOMOp::OpSharedShapes, operTbId );
|
||||||
|
createTool( GEOMOp::OpTransferData, operTbId );
|
||||||
|
|
||||||
int featTbId = createTool( tr( "TOOL_FEATURES" ), QString( "GEOMModification" ) );
|
int featTbId = createTool( tr( "TOOL_FEATURES" ), QString( "GEOMModification" ) );
|
||||||
createTool( GEOMOp::OpFillet1d, featTbId );
|
createTool( GEOMOp::OpFillet1d, featTbId );
|
||||||
|
@ -157,6 +157,7 @@ namespace GEOMOp {
|
|||||||
OpSharedShapes = 3708, // MENU OPERATION - GET SHARED SHAPES
|
OpSharedShapes = 3708, // MENU OPERATION - GET SHARED SHAPES
|
||||||
OpExtrudedBoss = 3709, // MENU OPERATION - ETRUDED BOSS
|
OpExtrudedBoss = 3709, // MENU OPERATION - ETRUDED BOSS
|
||||||
OpExtrudedCut = 3710, // MENU OPERATION - ETRUDED CUT
|
OpExtrudedCut = 3710, // MENU OPERATION - ETRUDED CUT
|
||||||
|
OpTransferData = 3711, // MENU OPERATION - TRANSFER DATA
|
||||||
// RepairGUI -------------------//--------------------------------
|
// RepairGUI -------------------//--------------------------------
|
||||||
OpSewing = 4000, // MENU REPAIR - SEWING
|
OpSewing = 4000, // MENU REPAIR - SEWING
|
||||||
OpSuppressFaces = 4001, // MENU REPAIR - SUPPRESS FACES
|
OpSuppressFaces = 4001, // MENU REPAIR - SUPPRESS FACES
|
||||||
|
@ -111,6 +111,7 @@ SET(GEOMImpl_HEADERS
|
|||||||
GEOMImpl_ICone.hxx
|
GEOMImpl_ICone.hxx
|
||||||
GEOMImpl_ISphere.hxx
|
GEOMImpl_ISphere.hxx
|
||||||
GEOMImpl_ITorus.hxx
|
GEOMImpl_ITorus.hxx
|
||||||
|
GEOMImpl_ITransferData.hxx
|
||||||
GEOMImpl_IPrism.hxx
|
GEOMImpl_IPrism.hxx
|
||||||
GEOMImpl_IPipe.hxx
|
GEOMImpl_IPipe.hxx
|
||||||
GEOMImpl_IPipePath.hxx
|
GEOMImpl_IPipePath.hxx
|
||||||
@ -197,6 +198,7 @@ SET(GEOMImpl_SOURCES
|
|||||||
GEOMImpl_IFieldOperations.cxx
|
GEOMImpl_IFieldOperations.cxx
|
||||||
GEOMImpl_IBaseIEOperations.cxx
|
GEOMImpl_IBaseIEOperations.cxx
|
||||||
GEOMImpl_IPolyline2D.cxx
|
GEOMImpl_IPolyline2D.cxx
|
||||||
|
GEOMImpl_ITransferData.cxx
|
||||||
GEOMImpl_Gen.cxx
|
GEOMImpl_Gen.cxx
|
||||||
GEOMImpl_PointDriver.cxx
|
GEOMImpl_PointDriver.cxx
|
||||||
GEOMImpl_VectorDriver.cxx
|
GEOMImpl_VectorDriver.cxx
|
||||||
|
@ -22,18 +22,29 @@
|
|||||||
|
|
||||||
#include "GEOMImpl_CopyDriver.hxx"
|
#include "GEOMImpl_CopyDriver.hxx"
|
||||||
#include "GEOMImpl_ICopy.hxx"
|
#include "GEOMImpl_ICopy.hxx"
|
||||||
|
#include "GEOMImpl_ITransferData.hxx"
|
||||||
#include "GEOMImpl_Types.hxx"
|
#include "GEOMImpl_Types.hxx"
|
||||||
#include "GEOM_Function.hxx"
|
#include "GEOM_Function.hxx"
|
||||||
#include "GEOM_Object.hxx"
|
#include "GEOM_Object.hxx"
|
||||||
|
#include "GEOMAlgo_GetInPlace.hxx"
|
||||||
|
#include "GEOMAlgo_GetInPlaceAPI.hxx"
|
||||||
|
|
||||||
#include <BRep_Tool.hxx>
|
|
||||||
#include <gp_Pnt.hxx>
|
|
||||||
#include <TopoDS.hxx>
|
|
||||||
#include <TopoDS_Shape.hxx>
|
#include <TopoDS_Shape.hxx>
|
||||||
#include <TopoDS_Vertex.hxx>
|
#include <TopExp.hxx>
|
||||||
#include <TopAbs.hxx>
|
|
||||||
#include <TNaming_CopyShape.hxx>
|
#include <TNaming_CopyShape.hxx>
|
||||||
#include <TColStd_IndexedDataMapOfTransientTransient.hxx>
|
#include <TColStd_IndexedDataMapOfTransientTransient.hxx>
|
||||||
|
#include <TFunction_Logbook.hxx>
|
||||||
|
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
|
||||||
|
#include <TopTools_IndexedMapOfShape.hxx>
|
||||||
|
#include <TopTools_ListIteratorOfListOfShape.hxx>
|
||||||
|
#include <TopTools_ListOfShape.hxx>
|
||||||
|
#include <TopTools_MapIteratorOfMapOfShape.hxx>
|
||||||
|
|
||||||
|
|
||||||
|
#define NB_DATUM 2
|
||||||
|
#define DATUM_NAME_INDEX 1
|
||||||
|
#define DATUM_MATERIAL_INDEX 2
|
||||||
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : GetID
|
//function : GetID
|
||||||
@ -65,6 +76,10 @@ Standard_Integer GEOMImpl_CopyDriver::Execute(TFunction_Logbook& log) const
|
|||||||
|
|
||||||
Standard_Integer aType = aFunction->GetType();
|
Standard_Integer aType = aFunction->GetType();
|
||||||
|
|
||||||
|
if (aType == TRANSFER_DATA) {
|
||||||
|
return transferData(log);
|
||||||
|
}
|
||||||
|
|
||||||
GEOMImpl_ICopy aCI (aFunction);
|
GEOMImpl_ICopy aCI (aFunction);
|
||||||
TopoDS_Shape aCopy;
|
TopoDS_Shape aCopy;
|
||||||
|
|
||||||
@ -129,6 +144,276 @@ GetCreationInformation(std::string& theOperationName,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//================================================================================
|
||||||
|
/*!
|
||||||
|
* \brief Performs Transfer Data operation.
|
||||||
|
*/
|
||||||
|
//================================================================================
|
||||||
|
|
||||||
|
Standard_Integer GEOMImpl_CopyDriver::transferData(TFunction_Logbook& log) const
|
||||||
|
{
|
||||||
|
Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
|
||||||
|
GEOMImpl_ITransferData aTD (aFunction);
|
||||||
|
Handle(GEOM_Function) aRef1 = aTD.GetRef1();
|
||||||
|
Handle(GEOM_Function) aRef2 = aTD.GetRef2();
|
||||||
|
|
||||||
|
if (aRef1.IsNull() || aRef2.IsNull()) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
TopoDS_Shape aShape1 = aRef1->GetValue();
|
||||||
|
TopoDS_Shape aShape2 = aRef2->GetValue();
|
||||||
|
const int aFindMethod = aTD.GetFindMethod();
|
||||||
|
TopTools_IndexedDataMapOfShapeListOfShape aMapSoDest;
|
||||||
|
TopTools_IndexedMapOfShape anIndices1;
|
||||||
|
|
||||||
|
TopExp::MapShapes(aShape1, anIndices1);
|
||||||
|
|
||||||
|
switch (aFindMethod) {
|
||||||
|
case TD_GET_IN_PLACE:
|
||||||
|
if (!getInPlace(aShape1, anIndices1, aShape2, aMapSoDest)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case TD_GET_IN_PLACE_OLD:
|
||||||
|
if (!getInPlaceOld(aRef1, anIndices1, aShape2, aMapSoDest)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case TD_GET_IN_PLACE_BY_HISTORY:
|
||||||
|
if (!getInPlaceByHistory(aRef1, anIndices1, aShape2, aRef2, aMapSoDest)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Perform copying names.
|
||||||
|
Handle(TColStd_HArray1OfExtendedString) aDatumName =
|
||||||
|
new TColStd_HArray1OfExtendedString(1, NB_DATUM);
|
||||||
|
Handle(TColStd_HArray1OfInteger) aDatumMaxVal =
|
||||||
|
new TColStd_HArray1OfInteger(1, NB_DATUM, 0);
|
||||||
|
Handle(TColStd_HArray1OfInteger) aDatumVal =
|
||||||
|
new TColStd_HArray1OfInteger(1, NB_DATUM, 0);
|
||||||
|
GEOMImpl_ITransferData aTD1(aRef1);
|
||||||
|
GEOMImpl_ITransferData aTD2(aRef2);
|
||||||
|
Standard_Integer i;
|
||||||
|
Standard_Integer aNbShapes = anIndices1.Extent();
|
||||||
|
TopTools_MapOfShape aMapFence;
|
||||||
|
|
||||||
|
aDatumName->SetValue(DATUM_NAME_INDEX, "GEOM_TRANSFER_DATA_NAMES");
|
||||||
|
aDatumName->SetValue(DATUM_MATERIAL_INDEX, "GEOM_TRANSFER_DATA_MATERIALS");
|
||||||
|
|
||||||
|
for (i = 1; i <= aNbShapes; ++i) {
|
||||||
|
const TopoDS_Shape &aSource = anIndices1.FindKey(i);
|
||||||
|
TCollection_AsciiString aName = aTD1.GetName(aSource);
|
||||||
|
TCollection_AsciiString aMaterial = aTD1.GetMaterial(aSource);
|
||||||
|
|
||||||
|
// Transfer name
|
||||||
|
if (!aName.IsEmpty()) {
|
||||||
|
aDatumMaxVal->ChangeValue(DATUM_NAME_INDEX)++;
|
||||||
|
|
||||||
|
if (aMapSoDest.Contains(aSource)) {
|
||||||
|
aDatumVal->ChangeValue(DATUM_NAME_INDEX)++;
|
||||||
|
|
||||||
|
// Copy name to the list of subshapes of the second shape.
|
||||||
|
const TopTools_ListOfShape &aListDest =
|
||||||
|
aMapSoDest.FindFromKey(aSource);
|
||||||
|
TopTools_ListIteratorOfListOfShape anIt(aListDest);
|
||||||
|
|
||||||
|
for (; anIt.More(); anIt.Next()) {
|
||||||
|
const TopoDS_Shape &aShapeDest = anIt.Value();
|
||||||
|
|
||||||
|
if (aMapFence.Add(aShapeDest)) {
|
||||||
|
aTD2.SetName(aShapeDest, aName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transfer Material
|
||||||
|
if (!aMaterial.IsEmpty()) {
|
||||||
|
aDatumMaxVal->ChangeValue(DATUM_MATERIAL_INDEX)++;
|
||||||
|
|
||||||
|
if (aMapSoDest.Contains(aSource)) {
|
||||||
|
aDatumVal->ChangeValue(DATUM_MATERIAL_INDEX)++;
|
||||||
|
|
||||||
|
// Copy material to the list of subshapes of the second shape.
|
||||||
|
const TopTools_ListOfShape &aListDest =
|
||||||
|
aMapSoDest.FindFromKey(aSource);
|
||||||
|
TopTools_ListIteratorOfListOfShape anIt(aListDest);
|
||||||
|
|
||||||
|
for (; anIt.More(); anIt.Next()) {
|
||||||
|
const TopoDS_Shape &aShapeDest = anIt.Value();
|
||||||
|
|
||||||
|
if (aMapFence.Add(aShapeDest)) {
|
||||||
|
aTD2.SetMaterial(aShapeDest, aMaterial);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Store results.
|
||||||
|
aTD.SetDatumName(aDatumName);
|
||||||
|
aTD.SetDatumMaxVal(aDatumMaxVal);
|
||||||
|
aTD.SetDatumVal(aDatumVal);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//================================================================================
|
||||||
|
/*!
|
||||||
|
* \brief For each subshape of the source shape compute coinsident sub-shapes
|
||||||
|
* of the destination shape using GetInPlace method.
|
||||||
|
*/
|
||||||
|
//================================================================================
|
||||||
|
|
||||||
|
Standard_Boolean GEOMImpl_CopyDriver::getInPlace
|
||||||
|
(const TopoDS_Shape &theSourceShape,
|
||||||
|
const TopTools_IndexedMapOfShape &theSourceIndices,
|
||||||
|
const TopoDS_Shape &theDestinationShape,
|
||||||
|
TopTools_IndexedDataMapOfShapeListOfShape &theMapSourceDest) const
|
||||||
|
{
|
||||||
|
// Searching for the sub-shapes inside theDestinationShape shape
|
||||||
|
GEOMAlgo_GetInPlace aGIP;
|
||||||
|
|
||||||
|
if (!GEOMAlgo_GetInPlaceAPI::GetInPlace
|
||||||
|
(theDestinationShape, theSourceShape, aGIP)) {
|
||||||
|
return Standard_False;
|
||||||
|
}
|
||||||
|
|
||||||
|
const GEOMAlgo_DataMapOfShapeMapOfShape &aShapesIn = aGIP.ShapesIn();
|
||||||
|
const GEOMAlgo_DataMapOfShapeMapOfShape &aShapesOn = aGIP.ShapesOn();
|
||||||
|
Standard_Integer i;
|
||||||
|
Standard_Integer j;
|
||||||
|
Standard_Integer aNbShapes = theSourceIndices.Extent();
|
||||||
|
|
||||||
|
for (i = 1; i <= aNbShapes; ++i) {
|
||||||
|
const TopoDS_Shape &aSource = theSourceIndices.FindKey(i);
|
||||||
|
TopTools_ListOfShape aListShapes2;
|
||||||
|
TopTools_MapOfShape aMapShapes2;
|
||||||
|
|
||||||
|
for (j = 0; j < 2; ++j) {
|
||||||
|
const GEOMAlgo_DataMapOfShapeMapOfShape &aShapes2 =
|
||||||
|
j == 0 ? aShapesIn : aShapesOn;
|
||||||
|
|
||||||
|
if (aShapes2.IsBound(aSource)) {
|
||||||
|
const TopTools_MapOfShape &aMapShapesDest =
|
||||||
|
aShapes2.Find(aSource);
|
||||||
|
TopTools_MapIteratorOfMapOfShape aMapIter(aMapShapesDest);
|
||||||
|
|
||||||
|
for (; aMapIter.More(); aMapIter.Next()) {
|
||||||
|
const TopoDS_Shape &aShapeDest = aMapIter.Key();
|
||||||
|
|
||||||
|
if (aMapShapes2.Add(aShapeDest)) {
|
||||||
|
aListShapes2.Append(aShapeDest);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!aListShapes2.IsEmpty()) {
|
||||||
|
theMapSourceDest.Add(aSource, aListShapes2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Standard_True;
|
||||||
|
}
|
||||||
|
|
||||||
|
//================================================================================
|
||||||
|
/*!
|
||||||
|
* \brief For each subshape of the source shape compute coinsident sub-shapes
|
||||||
|
* of the destination shape using an old implementation
|
||||||
|
* of GetInPlace algorithm.
|
||||||
|
*/
|
||||||
|
//================================================================================
|
||||||
|
|
||||||
|
Standard_Boolean GEOMImpl_CopyDriver::getInPlaceOld
|
||||||
|
(const Handle(GEOM_Function) &theSourceRef,
|
||||||
|
const TopTools_IndexedMapOfShape &theSourceIndices,
|
||||||
|
const TopoDS_Shape &theDestinationShape,
|
||||||
|
TopTools_IndexedDataMapOfShapeListOfShape &theMapSourceDest) const
|
||||||
|
{
|
||||||
|
const Standard_Integer aNbShapes = theSourceIndices.Extent();
|
||||||
|
Standard_Integer i;
|
||||||
|
Standard_Integer iErr;
|
||||||
|
TopTools_ListOfShape aModifiedList;
|
||||||
|
GEOMImpl_ITransferData aTDSource(theSourceRef);
|
||||||
|
|
||||||
|
for (i = 1; i <= aNbShapes; ++i) {
|
||||||
|
const TopoDS_Shape &aSource = theSourceIndices.FindKey(i);
|
||||||
|
TCollection_AsciiString aName = aTDSource.GetName(aSource);
|
||||||
|
TCollection_AsciiString aMaterial = aTDSource.GetMaterial(aSource);
|
||||||
|
|
||||||
|
if (aName.IsEmpty() && aMaterial.IsEmpty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Call old GetInPlace.
|
||||||
|
iErr = GEOMAlgo_GetInPlaceAPI::GetInPlaceOld
|
||||||
|
(theDestinationShape, aSource, aModifiedList);
|
||||||
|
|
||||||
|
if (iErr == 3) {
|
||||||
|
// Nothing is found. Skip.
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (iErr) {
|
||||||
|
// Error.
|
||||||
|
return Standard_False;
|
||||||
|
}
|
||||||
|
|
||||||
|
theMapSourceDest.Add(aSource, aModifiedList);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Standard_True;
|
||||||
|
}
|
||||||
|
|
||||||
|
//================================================================================
|
||||||
|
/*!
|
||||||
|
* \brief For each subshape of the source shape compute coinsident sub-shapes
|
||||||
|
* of the destination shape using GetInPlaceByHistory algorithm.
|
||||||
|
*/
|
||||||
|
//================================================================================
|
||||||
|
|
||||||
|
Standard_Boolean GEOMImpl_CopyDriver::getInPlaceByHistory
|
||||||
|
(const Handle(GEOM_Function) &theSourceRef,
|
||||||
|
const TopTools_IndexedMapOfShape &theSourceIndices,
|
||||||
|
const TopoDS_Shape &theDestinationShape,
|
||||||
|
const Handle(GEOM_Function) &theDestinationRef,
|
||||||
|
TopTools_IndexedDataMapOfShapeListOfShape &theMapSourceDest) const
|
||||||
|
{
|
||||||
|
const Standard_Integer aNbShapes = theSourceIndices.Extent();
|
||||||
|
Standard_Integer i;
|
||||||
|
GEOMImpl_ITransferData aTDSource(theSourceRef);
|
||||||
|
TopTools_IndexedMapOfShape aDestIndices;
|
||||||
|
|
||||||
|
TopExp::MapShapes(theDestinationShape, aDestIndices);
|
||||||
|
|
||||||
|
for (i = 1; i <= aNbShapes; ++i) {
|
||||||
|
const TopoDS_Shape &aSource = theSourceIndices.FindKey(i);
|
||||||
|
TCollection_AsciiString aName = aTDSource.GetName(aSource);
|
||||||
|
TCollection_AsciiString aMaterial = aTDSource.GetMaterial(aSource);
|
||||||
|
|
||||||
|
if (aName.IsEmpty() && aMaterial.IsEmpty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Call GetInPlaceByHistory.
|
||||||
|
TopTools_ListOfShape aModifiedList;
|
||||||
|
const Standard_Boolean isFound = GEOMAlgo_GetInPlaceAPI::GetInPlaceByHistory
|
||||||
|
(theDestinationRef, aDestIndices, aSource, aModifiedList);
|
||||||
|
|
||||||
|
if (isFound && !aModifiedList.IsEmpty()) {
|
||||||
|
theMapSourceDest.Add(aSource, aModifiedList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Standard_True;
|
||||||
|
}
|
||||||
|
|
||||||
IMPLEMENT_STANDARD_HANDLE (GEOMImpl_CopyDriver,GEOM_BaseDriver);
|
IMPLEMENT_STANDARD_HANDLE (GEOMImpl_CopyDriver,GEOM_BaseDriver);
|
||||||
|
|
||||||
IMPLEMENT_STANDARD_RTTIEXT (GEOMImpl_CopyDriver,GEOM_BaseDriver);
|
IMPLEMENT_STANDARD_RTTIEXT (GEOMImpl_CopyDriver,GEOM_BaseDriver);
|
||||||
|
@ -26,42 +26,15 @@
|
|||||||
#ifndef _GEOMImpl_CopyDriver_HeaderFile
|
#ifndef _GEOMImpl_CopyDriver_HeaderFile
|
||||||
#define _GEOMImpl_CopyDriver_HeaderFile
|
#define _GEOMImpl_CopyDriver_HeaderFile
|
||||||
|
|
||||||
#ifndef _TColStd_SequenceOfExtendedString_HeaderFile
|
class TopoDS_Shape;
|
||||||
#include <TColStd_SequenceOfExtendedString.hxx>
|
class TopTools_IndexedDataMapOfShapeListOfShape;
|
||||||
#endif
|
class TopTools_IndexedMapOfShape;
|
||||||
#ifndef _Standard_TypeMismatch_HeaderFile
|
class Standard_GUID;
|
||||||
#include <Standard_TypeMismatch.hxx>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _Standard_HeaderFile
|
|
||||||
#include <Standard.hxx>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _Standard_Macro_HeaderFile
|
|
||||||
#include <Standard_Macro.hxx>
|
|
||||||
#endif
|
|
||||||
#ifndef _Standard_HeaderFile
|
|
||||||
#include <Standard.hxx>
|
|
||||||
#endif
|
|
||||||
#ifndef _Standard_GUID_HeaderFile
|
|
||||||
#include <Standard_GUID.hxx>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _TFunction_Driver_HeaderFile
|
|
||||||
#include <TFunction_Driver.hxx>
|
|
||||||
#endif
|
|
||||||
#ifndef _TFunction_Logbook_HeaderFile
|
|
||||||
#include <TFunction_Logbook.hxx>
|
|
||||||
#endif
|
|
||||||
#ifndef _Standard_CString_HeaderFile
|
|
||||||
#include <Standard_CString.hxx>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class TColStd_SequenceOfExtendedString;
|
|
||||||
|
|
||||||
|
|
||||||
#include "GEOM_BaseDriver.hxx"
|
#include "GEOM_BaseDriver.hxx"
|
||||||
|
|
||||||
|
|
||||||
DEFINE_STANDARD_HANDLE( GEOMImpl_CopyDriver, GEOM_BaseDriver );
|
DEFINE_STANDARD_HANDLE( GEOMImpl_CopyDriver, GEOM_BaseDriver );
|
||||||
|
|
||||||
class GEOMImpl_CopyDriver : public GEOM_BaseDriver {
|
class GEOMImpl_CopyDriver : public GEOM_BaseDriver {
|
||||||
@ -82,6 +55,30 @@ Standard_EXPORT ~GEOMImpl_CopyDriver() {};
|
|||||||
std::vector<GEOM_Param>& params);
|
std::vector<GEOM_Param>& params);
|
||||||
|
|
||||||
DEFINE_STANDARD_RTTI( GEOMImpl_CopyDriver )
|
DEFINE_STANDARD_RTTI( GEOMImpl_CopyDriver )
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
Standard_Integer transferData(TFunction_Logbook& log) const;
|
||||||
|
|
||||||
|
Standard_Boolean getInPlace
|
||||||
|
(const TopoDS_Shape &theSourceShape,
|
||||||
|
const TopTools_IndexedMapOfShape &theSourceIndices,
|
||||||
|
const TopoDS_Shape &theDestinationShape,
|
||||||
|
TopTools_IndexedDataMapOfShapeListOfShape &theMapSourceDest) const;
|
||||||
|
|
||||||
|
Standard_Boolean getInPlaceOld
|
||||||
|
(const Handle(GEOM_Function) &theSourceShapeRef,
|
||||||
|
const TopTools_IndexedMapOfShape &theSourceIndices,
|
||||||
|
const TopoDS_Shape &theDestinationShape,
|
||||||
|
TopTools_IndexedDataMapOfShapeListOfShape &theMapSourceDest) const;
|
||||||
|
|
||||||
|
Standard_Boolean getInPlaceByHistory
|
||||||
|
(const Handle(GEOM_Function) &theSourceShapeRef,
|
||||||
|
const TopTools_IndexedMapOfShape &theSourceIndices,
|
||||||
|
const TopoDS_Shape &theDestinationShape,
|
||||||
|
const Handle(GEOM_Function) &theDestinationRef,
|
||||||
|
TopTools_IndexedDataMapOfShapeListOfShape &theMapSourceDest) const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
105
src/GEOMImpl/GEOMImpl_IInsertOperations.cxx
Executable file → Normal file
105
src/GEOMImpl/GEOMImpl_IInsertOperations.cxx
Executable file → Normal file
@ -29,6 +29,7 @@
|
|||||||
#include <GEOMImpl_ImportDriver.hxx>
|
#include <GEOMImpl_ImportDriver.hxx>
|
||||||
#include <GEOMImpl_ICopy.hxx>
|
#include <GEOMImpl_ICopy.hxx>
|
||||||
#include <GEOMImpl_IImportExport.hxx>
|
#include <GEOMImpl_IImportExport.hxx>
|
||||||
|
#include <GEOMImpl_ITransferData.hxx>
|
||||||
#include <GEOMImpl_Types.hxx>
|
#include <GEOMImpl_Types.hxx>
|
||||||
#include "GEOMImpl_IShapesOperations.hxx"
|
#include "GEOMImpl_IShapesOperations.hxx"
|
||||||
#include "GEOMImpl_IGroupOperations.hxx"
|
#include "GEOMImpl_IGroupOperations.hxx"
|
||||||
@ -340,3 +341,107 @@ std::list<int> GEOMImpl_IInsertOperations::GetAllTextures()
|
|||||||
SetErrorCode(OK);
|
SetErrorCode(OK);
|
||||||
return id_list;
|
return id_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=============================================================================
|
||||||
|
/*!
|
||||||
|
* TransferData
|
||||||
|
*/
|
||||||
|
//=============================================================================
|
||||||
|
bool GEOMImpl_IInsertOperations::TransferData
|
||||||
|
(const Handle(GEOM_Object) &theObjectFrom,
|
||||||
|
const Handle(GEOM_Object) &theObjectTo,
|
||||||
|
const int theFindMethod,
|
||||||
|
std::list<TransferDatum> &theResult)
|
||||||
|
{
|
||||||
|
SetErrorCode(KO);
|
||||||
|
|
||||||
|
if (theObjectFrom.IsNull() || theObjectTo.IsNull()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Add a new Transfer Data object object
|
||||||
|
Handle(GEOM_Object) aTDObj =
|
||||||
|
GetEngine()->AddObject(GetDocID(), GEOM_TRANSFER_DATA);
|
||||||
|
|
||||||
|
//Add a Transfer Data function for created object
|
||||||
|
Handle(GEOM_Function) aFunction =
|
||||||
|
aTDObj->AddFunction(GEOMImpl_CopyDriver::GetID(), TRANSFER_DATA);
|
||||||
|
|
||||||
|
//Check if the function is set correctly
|
||||||
|
if(aFunction->GetDriverGUID() != GEOMImpl_CopyDriver::GetID()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Handle(GEOM_Function) aFunctionFrom = theObjectFrom->GetLastFunction();
|
||||||
|
Handle(GEOM_Function) aFunctionTo = theObjectTo->GetLastFunction();
|
||||||
|
|
||||||
|
if (aFunctionFrom.IsNull() || aFunctionTo.IsNull()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
GEOMImpl_ITransferData aTD(aFunction);
|
||||||
|
|
||||||
|
aTD.SetRef1(aFunctionFrom);
|
||||||
|
aTD.SetRef2(aFunctionTo);
|
||||||
|
aTD.SetFindMethod(theFindMethod);
|
||||||
|
|
||||||
|
// Transfer data
|
||||||
|
try {
|
||||||
|
OCC_CATCH_SIGNALS;
|
||||||
|
if (!GetSolver()->ComputeFunction(aFunction)) {
|
||||||
|
SetErrorCode("Transfer data failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Standard_Failure) {
|
||||||
|
Handle(Standard_Failure) aFail = Standard_Failure::Caught();
|
||||||
|
SetErrorCode(aFail->GetMessageString());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fill result list of data.
|
||||||
|
theResult.clear();
|
||||||
|
|
||||||
|
Handle(TColStd_HArray1OfExtendedString) aDatumName = aTD.GetDatumName();
|
||||||
|
Handle(TColStd_HArray1OfInteger) aDatumMaxVal = aTD.GetDatumMaxVal();
|
||||||
|
Handle(TColStd_HArray1OfInteger) aDatumVal = aTD.GetDatumVal();
|
||||||
|
|
||||||
|
if (!aDatumName.IsNull() && !aDatumMaxVal.IsNull() && !aDatumVal.IsNull()) {
|
||||||
|
Standard_Integer i;
|
||||||
|
Standard_Integer aNbDatum = aDatumName->Length();
|
||||||
|
|
||||||
|
for (i = 1; i <= aNbDatum; ++i) {
|
||||||
|
if (aDatumMaxVal->Value(i) > 0) {
|
||||||
|
TransferDatum aDatum;
|
||||||
|
|
||||||
|
aDatum.myName = TCollection_AsciiString(aDatumName->Value(i));
|
||||||
|
aDatum.myNumber = aDatumVal->Value(i);
|
||||||
|
aDatum.myMaxNumber = aDatumMaxVal->Value(i);
|
||||||
|
theResult.push_back(aDatum);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Make a Python command
|
||||||
|
GEOM::TPythonDump pd (aFunction);
|
||||||
|
pd << "geompy.TransferData(" << theObjectFrom << ", " << theObjectTo;
|
||||||
|
pd << ", GEOM.";
|
||||||
|
|
||||||
|
switch (theFindMethod) {
|
||||||
|
case TD_GET_IN_PLACE:
|
||||||
|
pd << "FSM_GetInPlace";
|
||||||
|
break;
|
||||||
|
case TD_GET_IN_PLACE_OLD:
|
||||||
|
pd << "FSM_GetInPlace_Old";
|
||||||
|
break;
|
||||||
|
case TD_GET_IN_PLACE_BY_HISTORY:
|
||||||
|
default:
|
||||||
|
pd << "FSM_GetInPlaceByHistory";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
pd << ")";
|
||||||
|
|
||||||
|
SetErrorCode(OK);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
@ -49,6 +49,14 @@ class Handle_TColStd_HArray1OfByte;
|
|||||||
|
|
||||||
class GEOMImpl_IInsertOperations : public GEOM_IOperations {
|
class GEOMImpl_IInsertOperations : public GEOM_IOperations {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
struct TransferDatum
|
||||||
|
{
|
||||||
|
TCollection_AsciiString myName;
|
||||||
|
long myNumber;
|
||||||
|
long myMaxNumber;
|
||||||
|
};
|
||||||
|
|
||||||
Standard_EXPORT GEOMImpl_IInsertOperations(GEOM_Engine* theEngine, int theDocID);
|
Standard_EXPORT GEOMImpl_IInsertOperations(GEOM_Engine* theEngine, int theDocID);
|
||||||
Standard_EXPORT ~GEOMImpl_IInsertOperations();
|
Standard_EXPORT ~GEOMImpl_IInsertOperations();
|
||||||
|
|
||||||
@ -79,6 +87,12 @@ class GEOMImpl_IInsertOperations : public GEOM_IOperations {
|
|||||||
|
|
||||||
Standard_EXPORT std::list<int> GetAllTextures();
|
Standard_EXPORT std::list<int> GetAllTextures();
|
||||||
|
|
||||||
|
Standard_EXPORT bool TransferData
|
||||||
|
(const Handle(GEOM_Object) &theObjectFrom,
|
||||||
|
const Handle(GEOM_Object) &theObjectTo,
|
||||||
|
const int theFindMethod,
|
||||||
|
std::list<TransferDatum> &theResult);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<Handle(Resource_Manager)> myResMgrList;
|
std::vector<Handle(Resource_Manager)> myResMgrList;
|
||||||
GEOMImpl_IShapesOperations* myShapesOperations;
|
GEOMImpl_IShapesOperations* myShapesOperations;
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
// Author : modified by Lioka RAZAFINDRAZAKA (CEA) 22/06/2007
|
// Author : modified by Lioka RAZAFINDRAZAKA (CEA) 22/06/2007
|
||||||
// Project : SALOME
|
// Project : SALOME
|
||||||
|
|
||||||
#include <Standard_Stream.hxx>
|
//#include <Standard_Stream.hxx>
|
||||||
|
|
||||||
#include "GEOMImpl_IShapesOperations.hxx"
|
#include "GEOMImpl_IShapesOperations.hxx"
|
||||||
|
|
||||||
@ -55,62 +55,32 @@
|
|||||||
|
|
||||||
#include "GEOMAlgo_ClsfBox.hxx"
|
#include "GEOMAlgo_ClsfBox.hxx"
|
||||||
#include "GEOMAlgo_ClsfSolid.hxx"
|
#include "GEOMAlgo_ClsfSolid.hxx"
|
||||||
#include "GEOMAlgo_CoupleOfShapes.hxx"
|
|
||||||
#include "GEOMAlgo_FinderShapeOn1.hxx"
|
#include "GEOMAlgo_FinderShapeOn1.hxx"
|
||||||
#include "GEOMAlgo_FinderShapeOnQuad.hxx"
|
#include "GEOMAlgo_FinderShapeOnQuad.hxx"
|
||||||
#include "GEOMAlgo_FinderShapeOn2.hxx"
|
#include "GEOMAlgo_FinderShapeOn2.hxx"
|
||||||
#include "GEOMAlgo_GetInPlace.hxx"
|
#include "GEOMAlgo_GetInPlace.hxx"
|
||||||
|
#include "GEOMAlgo_GetInPlaceAPI.hxx"
|
||||||
#include "GEOMAlgo_GlueDetector.hxx"
|
#include "GEOMAlgo_GlueDetector.hxx"
|
||||||
#include "GEOMAlgo_ListIteratorOfListOfCoupleOfShapes.hxx"
|
|
||||||
#include "GEOMAlgo_ListOfCoupleOfShapes.hxx"
|
|
||||||
|
|
||||||
#include <Basics_OCCTVersion.hxx>
|
|
||||||
|
|
||||||
#include <utilities.h>
|
#include <utilities.h>
|
||||||
#include <OpUtil.hxx>
|
|
||||||
#include <Utils_ExceptHandlers.hxx>
|
|
||||||
|
|
||||||
#include <BRepAdaptor_Curve.hxx>
|
#include <BRepAdaptor_Curve.hxx>
|
||||||
#include <BRepAdaptor_Surface.hxx>
|
#include <BRepAdaptor_Surface.hxx>
|
||||||
#include <BRepBndLib.hxx>
|
|
||||||
#include <BRepBuilderAPI_MakeVertex.hxx>
|
|
||||||
#include <BRepClass3d_SolidClassifier.hxx>
|
|
||||||
#include <BRepClass_FaceClassifier.hxx>
|
|
||||||
#include <BRepExtrema_DistShapeShape.hxx>
|
|
||||||
#include <BRepExtrema_ExtCF.hxx>
|
|
||||||
#include <BRepGProp.hxx>
|
|
||||||
#include <BRepMesh_IncrementalMesh.hxx>
|
|
||||||
#include <BRepTools.hxx>
|
#include <BRepTools.hxx>
|
||||||
#include <BRep_Builder.hxx>
|
#include <BRep_Builder.hxx>
|
||||||
#include <BRep_Tool.hxx>
|
#include <BRep_Tool.hxx>
|
||||||
#include <Bnd_Box.hxx>
|
|
||||||
#include <GEOMImpl_IMeasure.hxx>
|
|
||||||
#include <GEOMImpl_MeasureDriver.hxx>
|
|
||||||
#include <GProp_GProps.hxx>
|
|
||||||
#include <Geom2d_Curve.hxx>
|
|
||||||
#include <GeomAdaptor_Surface.hxx>
|
|
||||||
#include <GeomLib_Tool.hxx>
|
#include <GeomLib_Tool.hxx>
|
||||||
#include <Geom_CylindricalSurface.hxx>
|
#include <Geom_CylindricalSurface.hxx>
|
||||||
#include <Geom_Plane.hxx>
|
#include <Geom_Plane.hxx>
|
||||||
#include <Geom_SphericalSurface.hxx>
|
#include <Geom_SphericalSurface.hxx>
|
||||||
#include <Geom_Surface.hxx>
|
#include <Geom_Surface.hxx>
|
||||||
#include <Precision.hxx>
|
#include <Precision.hxx>
|
||||||
#include <TColStd_Array1OfReal.hxx>
|
|
||||||
#include <TColStd_HArray1OfInteger.hxx>
|
#include <TColStd_HArray1OfInteger.hxx>
|
||||||
#include <TColStd_ListIteratorOfListOfInteger.hxx>
|
|
||||||
#include <TColStd_ListOfInteger.hxx>
|
|
||||||
#include <TDF_Tool.hxx>
|
#include <TDF_Tool.hxx>
|
||||||
#include <TDataStd_Integer.hxx>
|
#include <TDataStd_Integer.hxx>
|
||||||
#include <TDataStd_IntegerArray.hxx>
|
|
||||||
#include <TDataStd_ListIteratorOfListOfExtendedString.hxx>
|
#include <TDataStd_ListIteratorOfListOfExtendedString.hxx>
|
||||||
#include <TFunction_Driver.hxx>
|
|
||||||
#include <TFunction_DriverTable.hxx>
|
|
||||||
#include <TFunction_Logbook.hxx>
|
|
||||||
#include <TopAbs.hxx>
|
|
||||||
#include <TopExp.hxx>
|
#include <TopExp.hxx>
|
||||||
#include <TopExp_Explorer.hxx>
|
#include <TopExp_Explorer.hxx>
|
||||||
#include <TopLoc_Location.hxx>
|
|
||||||
#include <TopTools_Array1OfShape.hxx>
|
|
||||||
#include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
|
#include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
|
||||||
#include <TopTools_IndexedMapOfShape.hxx>
|
#include <TopTools_IndexedMapOfShape.hxx>
|
||||||
#include <TopTools_ListIteratorOfListOfShape.hxx>
|
#include <TopTools_ListIteratorOfListOfShape.hxx>
|
||||||
@ -126,59 +96,15 @@
|
|||||||
#include <TopoDS_Solid.hxx>
|
#include <TopoDS_Solid.hxx>
|
||||||
#include <TopoDS_Vertex.hxx>
|
#include <TopoDS_Vertex.hxx>
|
||||||
#include <gp_Cylinder.hxx>
|
#include <gp_Cylinder.hxx>
|
||||||
#include <gp_Lin.hxx>
|
|
||||||
#include <gp_Pnt.hxx>
|
#include <gp_Pnt.hxx>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <algorithm>
|
|
||||||
#include <functional>
|
|
||||||
|
|
||||||
#include <Standard_NullObject.hxx>
|
|
||||||
#include <Standard_Failure.hxx>
|
#include <Standard_Failure.hxx>
|
||||||
#include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
|
#include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
//================================================================================
|
|
||||||
/*!
|
|
||||||
* \brief Return normal to face at extrema point
|
|
||||||
*/
|
|
||||||
//================================================================================
|
|
||||||
|
|
||||||
gp_Vec GetNormal (const TopoDS_Face& face, const BRepExtrema_DistShapeShape& extrema)
|
|
||||||
{
|
|
||||||
gp_Vec defaultNorm(1,0,0); // to have same normals on different faces
|
|
||||||
try {
|
|
||||||
// get UV at extrema point
|
|
||||||
Standard_Real u,v, f,l;
|
|
||||||
switch ( extrema.SupportTypeShape2(1) ) {
|
|
||||||
case BRepExtrema_IsInFace: {
|
|
||||||
extrema.ParOnFaceS2(1, u, v );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case BRepExtrema_IsOnEdge: {
|
|
||||||
TopoDS_Edge edge = TopoDS::Edge( extrema.SupportOnShape2(1));
|
|
||||||
Handle(Geom2d_Curve) pcurve = BRep_Tool::CurveOnSurface( edge, face, f,l );
|
|
||||||
extrema.ParOnEdgeS2( 1, u );
|
|
||||||
gp_Pnt2d uv = pcurve->Value( u );
|
|
||||||
u = uv.Coord(1);
|
|
||||||
v = uv.Coord(2);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case BRepExtrema_IsVertex: return defaultNorm;
|
|
||||||
}
|
|
||||||
// get derivatives
|
|
||||||
BRepAdaptor_Surface surface( face, false );
|
|
||||||
gp_Vec du, dv; gp_Pnt p;
|
|
||||||
surface.D1( u, v, p, du, dv );
|
|
||||||
|
|
||||||
return du ^ dv;
|
|
||||||
|
|
||||||
} catch (Standard_Failure ) {
|
|
||||||
}
|
|
||||||
return defaultNorm;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AddFlatSubShapes(const TopoDS_Shape& S, TopTools_ListOfShape& L, TopTools_MapOfShape& M)
|
void AddFlatSubShapes(const TopoDS_Shape& S, TopTools_ListOfShape& L, TopTools_MapOfShape& M)
|
||||||
{
|
{
|
||||||
if (S.ShapeType() != TopAbs_COMPOUND) {
|
if (S.ShapeType() != TopAbs_COMPOUND) {
|
||||||
@ -3966,165 +3892,6 @@ Handle(TColStd_HSequenceOfInteger)
|
|||||||
return aSeqOfIDs;
|
return aSeqOfIDs;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=============================================================================
|
|
||||||
/*!
|
|
||||||
* GetInPlaceOfShape
|
|
||||||
*/
|
|
||||||
//=============================================================================
|
|
||||||
static bool GetInPlaceOfShape (const Handle(GEOM_Function)& theWhereFunction,
|
|
||||||
const TopTools_IndexedMapOfShape& theWhereIndices,
|
|
||||||
const TopoDS_Shape& theWhat,
|
|
||||||
TColStd_ListOfInteger& theModifiedList)
|
|
||||||
{
|
|
||||||
if (theWhereFunction.IsNull() || theWhat.IsNull()) return false;
|
|
||||||
|
|
||||||
if (theWhereIndices.Contains(theWhat)) {
|
|
||||||
// entity was not changed by the operation
|
|
||||||
Standard_Integer aWhatIndex = theWhereIndices.FindIndex(theWhat);
|
|
||||||
theModifiedList.Append(aWhatIndex);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// try to find in history
|
|
||||||
TDF_Label aHistoryLabel = theWhereFunction->GetHistoryEntry(Standard_False);
|
|
||||||
|
|
||||||
// search in history for all argument shapes
|
|
||||||
Standard_Boolean isFound = Standard_False;
|
|
||||||
Standard_Boolean isGood = Standard_False;
|
|
||||||
|
|
||||||
TDF_LabelSequence aLabelSeq;
|
|
||||||
theWhereFunction->GetDependency(aLabelSeq);
|
|
||||||
Standard_Integer nbArg = aLabelSeq.Length();
|
|
||||||
|
|
||||||
for (Standard_Integer iarg = 1; iarg <= nbArg && !isFound; iarg++) {
|
|
||||||
|
|
||||||
TDF_Label anArgumentRefLabel = aLabelSeq.Value(iarg);
|
|
||||||
|
|
||||||
Handle(GEOM_Object) anArgumentObject = GEOM_Object::GetReferencedObject(anArgumentRefLabel);
|
|
||||||
TopoDS_Shape anArgumentShape = anArgumentObject->GetValue();
|
|
||||||
|
|
||||||
TopTools_IndexedMapOfShape anArgumentIndices;
|
|
||||||
TopExp::MapShapes(anArgumentShape, anArgumentIndices);
|
|
||||||
|
|
||||||
if (anArgumentIndices.Contains(theWhat)) {
|
|
||||||
isFound = Standard_True;
|
|
||||||
Standard_Integer aWhatIndex = anArgumentIndices.FindIndex(theWhat);
|
|
||||||
|
|
||||||
// Find corresponding label in history
|
|
||||||
TDF_Label anArgumentHistoryLabel =
|
|
||||||
theWhereFunction->GetArgumentHistoryEntry(anArgumentRefLabel, Standard_False);
|
|
||||||
if (anArgumentHistoryLabel.IsNull()) {
|
|
||||||
// Lost History of operation argument. Possibly, all its entities was removed.
|
|
||||||
isGood = Standard_True;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
TDF_Label aWhatHistoryLabel = anArgumentHistoryLabel.FindChild(aWhatIndex, Standard_False);
|
|
||||||
|
|
||||||
if (aWhatHistoryLabel.IsNull()) {
|
|
||||||
// Removed entity ? Compound ? Compsolid ? Shell ? Wire
|
|
||||||
isGood = Standard_False;
|
|
||||||
} else {
|
|
||||||
Handle(TDataStd_IntegerArray) anIntegerArray;
|
|
||||||
if (!aWhatHistoryLabel.FindAttribute(TDataStd_IntegerArray::GetID(), anIntegerArray)) {
|
|
||||||
//Error: Empty modifications history for the sought shape.
|
|
||||||
isGood = Standard_False;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
isGood = Standard_True;
|
|
||||||
Standard_Integer imod, aModifLen = anIntegerArray->Array()->Length();
|
|
||||||
for (imod = 1; imod <= aModifLen; imod++) {
|
|
||||||
theModifiedList.Append(anIntegerArray->Array()->Value(imod));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
isFound = isGood;
|
|
||||||
|
|
||||||
if (!isFound) {
|
|
||||||
// try compound/compsolid/shell/wire element by element
|
|
||||||
bool isFoundAny = false;
|
|
||||||
TopTools_MapOfShape mapShape;
|
|
||||||
|
|
||||||
if (theWhat.ShapeType() == TopAbs_COMPOUND ||
|
|
||||||
theWhat.ShapeType() == TopAbs_COMPSOLID) {
|
|
||||||
// recursive processing of compound/compsolid
|
|
||||||
TopoDS_Iterator anIt (theWhat, Standard_True, Standard_True);
|
|
||||||
for (; anIt.More(); anIt.Next()) {
|
|
||||||
if (mapShape.Add(anIt.Value())) {
|
|
||||||
TopoDS_Shape curWhat = anIt.Value();
|
|
||||||
isFoundAny = GetInPlaceOfShape(theWhereFunction, theWhereIndices, curWhat, theModifiedList);
|
|
||||||
if (isFoundAny) isFound = Standard_True;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (theWhat.ShapeType() == TopAbs_SHELL) {
|
|
||||||
// try to replace a shell by its faces images
|
|
||||||
TopExp_Explorer anExp (theWhat, TopAbs_FACE);
|
|
||||||
for (; anExp.More(); anExp.Next()) {
|
|
||||||
if (mapShape.Add(anExp.Current())) {
|
|
||||||
TopoDS_Shape curWhat = anExp.Current();
|
|
||||||
isFoundAny = GetInPlaceOfShape(theWhereFunction, theWhereIndices, curWhat, theModifiedList);
|
|
||||||
if (isFoundAny) isFound = Standard_True;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (theWhat.ShapeType() == TopAbs_WIRE) {
|
|
||||||
// try to replace a wire by its edges images
|
|
||||||
TopExp_Explorer anExp (theWhat, TopAbs_EDGE);
|
|
||||||
for (; anExp.More(); anExp.Next()) {
|
|
||||||
if (mapShape.Add(anExp.Current())) {
|
|
||||||
TopoDS_Shape curWhat = anExp.Current();
|
|
||||||
isFoundAny = GetInPlaceOfShape(theWhereFunction, theWhereIndices, curWhat, theModifiedList);
|
|
||||||
if (isFoundAny) isFound = Standard_True;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// Removed entity
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return isFound;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=============================================================================
|
|
||||||
/*!
|
|
||||||
* GetShapeProperties
|
|
||||||
*/
|
|
||||||
//=============================================================================
|
|
||||||
void GEOMImpl_IShapesOperations::GetShapeProperties( const TopoDS_Shape aShape, Standard_Real tab[],
|
|
||||||
gp_Pnt & aVertex )
|
|
||||||
{
|
|
||||||
GProp_GProps theProps;
|
|
||||||
gp_Pnt aCenterMass;
|
|
||||||
//TopoDS_Shape aPntShape;
|
|
||||||
Standard_Real aShapeSize;
|
|
||||||
|
|
||||||
if (aShape.ShapeType() == TopAbs_VERTEX) aCenterMass = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) );
|
|
||||||
else if (aShape.ShapeType() == TopAbs_EDGE) BRepGProp::LinearProperties(aShape, theProps);
|
|
||||||
else if (aShape.ShapeType() == TopAbs_FACE) BRepGProp::SurfaceProperties(aShape, theProps);
|
|
||||||
else BRepGProp::VolumeProperties(aShape, theProps);
|
|
||||||
|
|
||||||
if (aShape.ShapeType() == TopAbs_VERTEX)
|
|
||||||
aShapeSize = 1;
|
|
||||||
else {
|
|
||||||
aCenterMass = theProps.CentreOfMass();
|
|
||||||
aShapeSize = theProps.Mass();
|
|
||||||
}
|
|
||||||
|
|
||||||
// aPntShape = BRepBuilderAPI_MakeVertex(aCenterMass).Shape();
|
|
||||||
// aVertex = BRep_Tool::Pnt( TopoDS::Vertex( aPntShape ) );
|
|
||||||
aVertex = aCenterMass;
|
|
||||||
tab[0] = aVertex.X();
|
|
||||||
tab[1] = aVertex.Y();
|
|
||||||
tab[2] = aVertex.Z();
|
|
||||||
tab[3] = aShapeSize;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
/*!
|
/*!
|
||||||
* case GetInPlace:
|
* case GetInPlace:
|
||||||
@ -4146,47 +3913,10 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetInPlace (Handle(GEOM_Object)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compute confusion tolerance.
|
|
||||||
Standard_Real aTolConf = Precision::Confusion();
|
|
||||||
Standard_Integer i;
|
|
||||||
|
|
||||||
for (i = 0; i < 2; ++i) {
|
|
||||||
TopExp_Explorer anExp(i == 0 ? aWhere : aWhat, TopAbs_VERTEX);
|
|
||||||
|
|
||||||
for (; anExp.More(); anExp.Next()) {
|
|
||||||
const TopoDS_Vertex aVtx = TopoDS::Vertex(anExp.Current());
|
|
||||||
const Standard_Real aTolVtx = BRep_Tool::Tolerance(aVtx);
|
|
||||||
|
|
||||||
if (aTolVtx > aTolConf) {
|
|
||||||
aTolConf = aTolVtx;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Compute mass tolerance.
|
|
||||||
Bnd_Box aBoundingBox;
|
|
||||||
Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
|
|
||||||
Standard_Real aMassTol;
|
|
||||||
|
|
||||||
BRepBndLib::Add(aWhere, aBoundingBox);
|
|
||||||
BRepBndLib::Add(aWhat, aBoundingBox);
|
|
||||||
aBoundingBox.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
|
|
||||||
aMassTol = Max(aXmax - aXmin, aYmax - aYmin);
|
|
||||||
aMassTol = Max(aMassTol, aZmax - aZmin);
|
|
||||||
aMassTol *= aTolConf;
|
|
||||||
|
|
||||||
// Searching for the sub-shapes inside the ShapeWhere shape
|
// Searching for the sub-shapes inside the ShapeWhere shape
|
||||||
GEOMAlgo_GetInPlace aGIP;
|
GEOMAlgo_GetInPlace aGIP;
|
||||||
aGIP.SetTolerance(aTolConf);
|
|
||||||
aGIP.SetTolMass(aMassTol);
|
|
||||||
aGIP.SetTolCG(aTolConf);
|
|
||||||
|
|
||||||
aGIP.SetArgument(aWhat);
|
if (!GEOMAlgo_GetInPlaceAPI::GetInPlace(aWhere, aWhat, aGIP)) {
|
||||||
aGIP.SetShapeWhere(aWhere);
|
|
||||||
|
|
||||||
aGIP.Perform();
|
|
||||||
int iErr = aGIP.ErrorStatus();
|
|
||||||
if (iErr) {
|
|
||||||
SetErrorCode("Error in GEOMAlgo_GetInPlace");
|
SetErrorCode("Error in GEOMAlgo_GetInPlace");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -4263,201 +3993,59 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetInPlace (Handle(GEOM_Object)
|
|||||||
* default:
|
* default:
|
||||||
*/
|
*/
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetInPlaceOld (Handle(GEOM_Object) theShapeWhere,
|
Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetInPlaceOld
|
||||||
Handle(GEOM_Object) theShapeWhat)
|
(Handle(GEOM_Object) theShapeWhere,
|
||||||
|
Handle(GEOM_Object) theShapeWhat)
|
||||||
{
|
{
|
||||||
SetErrorCode(KO);
|
SetErrorCode(KO);
|
||||||
|
|
||||||
if (theShapeWhere.IsNull() || theShapeWhat.IsNull()) return NULL;
|
if (theShapeWhere.IsNull() || theShapeWhat.IsNull()) return NULL;
|
||||||
|
|
||||||
TopoDS_Shape aWhere = theShapeWhere->GetValue();
|
TopoDS_Shape aWhere = theShapeWhere->GetValue();
|
||||||
TopoDS_Shape aWhat = theShapeWhat->GetValue();
|
TopoDS_Shape aWhat = theShapeWhat->GetValue();
|
||||||
TopoDS_Shape aPntShape;
|
TopTools_ListOfShape aModifiedList;
|
||||||
TopoDS_Vertex aVertex;
|
const Standard_Integer iErr =
|
||||||
|
GEOMAlgo_GetInPlaceAPI::GetInPlaceOld(aWhere, aWhat, aModifiedList);
|
||||||
|
|
||||||
if (aWhere.IsNull() || aWhat.IsNull()) {
|
if (iErr) {
|
||||||
SetErrorCode("Error: aWhere and aWhat TopoDS_Shape are Null.");
|
switch (iErr) {
|
||||||
return NULL;
|
case 1:
|
||||||
}
|
SetErrorCode("Error: aWhere and aWhat TopoDS_Shape are Null.");
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
SetErrorCode
|
||||||
|
("Error: An attempt to extract a shape of not supported type.");
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
SetErrorCode(NOT_FOUND_ANY);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
SetErrorCode("Shape driver failed");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
Handle(GEOM_Function) aWhereFunction = theShapeWhere->GetLastFunction();
|
|
||||||
if (aWhereFunction.IsNull()) {
|
|
||||||
SetErrorCode("Error: aWhereFunction is Null.");
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
TopTools_IndexedMapOfShape aWhereIndices;
|
TopTools_IndexedMapOfShape aWhereIndices;
|
||||||
TopExp::MapShapes(aWhere, aWhereIndices);
|
TopExp::MapShapes(aWhere, aWhereIndices);
|
||||||
|
|
||||||
TColStd_ListOfInteger aModifiedList;
|
Handle(TColStd_HArray1OfInteger) aModifiedArray =
|
||||||
Standard_Integer aWhereIndex;
|
new TColStd_HArray1OfInteger (1, aModifiedList.Extent());
|
||||||
Handle(TColStd_HArray1OfInteger) aModifiedArray;
|
TopTools_ListIteratorOfListOfShape anIterModif (aModifiedList);
|
||||||
Handle(GEOM_Object) aResult;
|
Standard_Integer imod;
|
||||||
|
|
||||||
bool isFound = false;
|
for (imod = 1; anIterModif.More(); anIterModif.Next(), imod++) {
|
||||||
TopAbs_ShapeEnum iType = TopAbs_SOLID;
|
const Standard_Integer anIndex =
|
||||||
//Standard_Real aWhat_Mass = 0., aWhere_Mass = 0.;
|
aWhereIndices.FindIndex(anIterModif.Value());
|
||||||
Standard_Real tab_aWhat[4], tab_aWhere[4];
|
|
||||||
Standard_Real dl_l = 1e-3;
|
|
||||||
Standard_Real min_l, Tol_0D, Tol_1D, Tol_2D, Tol_3D, Tol_Mass;
|
|
||||||
Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
|
|
||||||
Bnd_Box BoundingBox;
|
|
||||||
gp_Pnt aPnt, aPnt_aWhat, tab_Pnt[2];
|
|
||||||
GProp_GProps aProps;
|
|
||||||
|
|
||||||
// Find the iType of the aWhat shape
|
aModifiedArray->SetValue(imod, anIndex);
|
||||||
/*
|
|
||||||
if ( aWhat.ShapeType() == TopAbs_VERTEX ) iType = TopAbs_VERTEX;
|
|
||||||
else if ( aWhat.ShapeType() == TopAbs_EDGE || aWhat.ShapeType() == TopAbs_WIRE ) iType = TopAbs_EDGE;
|
|
||||||
else if ( aWhat.ShapeType() == TopAbs_FACE || aWhat.ShapeType() == TopAbs_SHELL ) iType = TopAbs_FACE;
|
|
||||||
else if ( aWhat.ShapeType() == TopAbs_SOLID || aWhat.ShapeType() == TopAbs_COMPSOLID ) iType = TopAbs_SOLID;
|
|
||||||
else if ( aWhat.ShapeType() == TopAbs_COMPOUND ) {
|
|
||||||
// Only the iType of the first shape in the compound is taken into account
|
|
||||||
TopoDS_Iterator It (aWhat, Standard_False, Standard_False);
|
|
||||||
if ( !It.More() ) {
|
|
||||||
SetErrorCode("Error: theShapeWhat is an empty COMPOUND.");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
TopAbs_ShapeEnum compType = It.Value().ShapeType();
|
|
||||||
if ( compType == TopAbs_VERTEX ) iType = TopAbs_VERTEX;
|
|
||||||
else if ( compType == TopAbs_EDGE || compType == TopAbs_WIRE ) iType = TopAbs_EDGE;
|
|
||||||
else if ( compType == TopAbs_FACE || compType == TopAbs_SHELL) iType = TopAbs_FACE;
|
|
||||||
else if ( compType == TopAbs_SOLID || compType == TopAbs_COMPSOLID) iType = TopAbs_SOLID;
|
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
SetErrorCode("Error: An attempt to extract a shape of not supported type.");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
iType = GEOMUtils::GetTypeOfSimplePart(aWhat);
|
|
||||||
if (iType == TopAbs_SHAPE) {
|
|
||||||
SetErrorCode("Error: An attempt to extract a shape of not supported type.");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
TopExp_Explorer Exp_aWhat ( aWhat, iType );
|
|
||||||
TopExp_Explorer Exp_aWhere ( aWhere, iType );
|
|
||||||
TopExp_Explorer Exp_Edge ( aWhere, TopAbs_EDGE );
|
|
||||||
|
|
||||||
// Find the shortest edge in theShapeWhere shape
|
|
||||||
BRepBndLib::Add(aWhere, BoundingBox);
|
|
||||||
BoundingBox.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
|
|
||||||
min_l = fabs(aXmax - aXmin);
|
|
||||||
if( min_l < fabs(aYmax - aYmin) ) min_l = fabs(aYmax - aYmin);
|
|
||||||
if( min_l < fabs(aZmax - aZmin) ) min_l = fabs(aZmax - aZmin);
|
|
||||||
min_l /= dl_l;
|
|
||||||
// Mantis issue 0020908 BEGIN
|
|
||||||
if (!Exp_Edge.More()) {
|
|
||||||
min_l = Precision::Confusion();
|
|
||||||
}
|
|
||||||
// Mantis issue 0020908 END
|
|
||||||
for ( Standard_Integer nbEdge = 0; Exp_Edge.More(); Exp_Edge.Next(), nbEdge++ ) {
|
|
||||||
TopExp_Explorer Exp_Vertex( Exp_Edge.Current(), TopAbs_VERTEX);
|
|
||||||
for ( Standard_Integer nbVertex = 0; Exp_Vertex.More(); Exp_Vertex.Next(), nbVertex++ ) {
|
|
||||||
aPnt = BRep_Tool::Pnt( TopoDS::Vertex( Exp_Vertex.Current() ) );
|
|
||||||
tab_Pnt[nbVertex] = aPnt;
|
|
||||||
}
|
|
||||||
if ( ! tab_Pnt[0].IsEqual(tab_Pnt[1], dl_l) ) {
|
|
||||||
BRepGProp::LinearProperties(Exp_Edge.Current(), aProps);
|
|
||||||
if ( aProps.Mass() < min_l ) min_l = aProps.Mass();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Compute tolerances
|
|
||||||
Tol_0D = dl_l;
|
|
||||||
Tol_1D = dl_l * min_l;
|
|
||||||
Tol_2D = dl_l * ( min_l * min_l) * ( 2. + dl_l);
|
|
||||||
Tol_3D = dl_l * ( min_l * min_l * min_l ) * ( 3. + (3 * dl_l) + (dl_l * dl_l) );
|
|
||||||
|
|
||||||
if (Tol_0D < Precision::Confusion()) Tol_0D = Precision::Confusion();
|
|
||||||
if (Tol_1D < Precision::Confusion()) Tol_1D = Precision::Confusion();
|
|
||||||
if (Tol_2D < Precision::Confusion()) Tol_2D = Precision::Confusion();
|
|
||||||
if (Tol_3D < Precision::Confusion()) Tol_3D = Precision::Confusion();
|
|
||||||
|
|
||||||
//if (Tol_1D > 1.0) Tol_1D = 1.0;
|
|
||||||
//if (Tol_2D > 1.0) Tol_2D = 1.0;
|
|
||||||
//if (Tol_3D > 1.0) Tol_3D = 1.0;
|
|
||||||
|
|
||||||
Tol_Mass = Tol_3D;
|
|
||||||
if ( iType == TopAbs_VERTEX ) Tol_Mass = Tol_0D;
|
|
||||||
else if ( iType == TopAbs_EDGE ) Tol_Mass = Tol_1D;
|
|
||||||
else if ( iType == TopAbs_FACE ) Tol_Mass = Tol_2D;
|
|
||||||
|
|
||||||
// Compute the ShapeWhat Mass
|
|
||||||
/*
|
|
||||||
for ( ; Exp_aWhat.More(); Exp_aWhat.Next() ) {
|
|
||||||
if ( iType == TopAbs_VERTEX ) {
|
|
||||||
aWhat_Mass += 1;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else if ( iType == TopAbs_EDGE ) BRepGProp::LinearProperties(Exp_aWhat.Current(), aProps);
|
|
||||||
else if ( iType == TopAbs_FACE ) BRepGProp::SurfaceProperties(Exp_aWhat.Current(), aProps);
|
|
||||||
else BRepGProp::VolumeProperties(Exp_aWhat.Current(), aProps);
|
|
||||||
aWhat_Mass += aProps.Mass();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Searching for the sub-shapes inside the ShapeWhere shape
|
|
||||||
TopTools_MapOfShape map_aWhere;
|
|
||||||
for ( Exp_aWhere.ReInit(); Exp_aWhere.More(); Exp_aWhere.Next() ) {
|
|
||||||
if (!map_aWhere.Add(Exp_aWhere.Current()))
|
|
||||||
continue; // skip repeated shape to avoid mass addition
|
|
||||||
GetShapeProperties( Exp_aWhere.Current(), tab_aWhere, aPnt );
|
|
||||||
for ( Exp_aWhat.ReInit(); Exp_aWhat.More(); Exp_aWhat.Next() ) {
|
|
||||||
GetShapeProperties( Exp_aWhat.Current(), tab_aWhat, aPnt_aWhat );
|
|
||||||
if ( fabs(tab_aWhat[3] - tab_aWhere[3]) <= Tol_Mass && aPnt_aWhat.Distance(aPnt) <= Tol_1D )
|
|
||||||
isFound = true;
|
|
||||||
else {
|
|
||||||
if ( (tab_aWhat[3] - tab_aWhere[3]) > Tol_Mass ) {
|
|
||||||
aPntShape = BRepBuilderAPI_MakeVertex( aPnt ).Shape();
|
|
||||||
aVertex = TopoDS::Vertex( aPntShape );
|
|
||||||
BRepExtrema_DistShapeShape aWhereDistance ( aVertex, Exp_aWhere.Current() );
|
|
||||||
BRepExtrema_DistShapeShape aWhatDistance ( aVertex, Exp_aWhat.Current() );
|
|
||||||
if ( aWhereDistance.IsDone() && aWhatDistance.IsDone() &&
|
|
||||||
fabs(aWhereDistance.Value() - aWhatDistance.Value()) <= Tol_1D )
|
|
||||||
{
|
|
||||||
// 0020162: "EDF 961 GEOM : Getinplace is getting additionnal orthogonal faces"
|
|
||||||
// aVertex must be projected to the same point on Where and on What
|
|
||||||
gp_Pnt pOnWhat = aWhatDistance.PointOnShape2(1);
|
|
||||||
gp_Pnt pOnWhere = aWhereDistance.PointOnShape2(1);
|
|
||||||
isFound = ( pOnWhat.Distance(pOnWhere) <= Tol_1D );
|
|
||||||
if ( isFound && iType == TopAbs_FACE )
|
|
||||||
{
|
|
||||||
// check normals at pOnWhat and pOnWhere
|
|
||||||
const double angleTol = M_PI/180.;
|
|
||||||
gp_Vec normToWhat = GetNormal( TopoDS::Face(Exp_aWhat.Current()), aWhatDistance);
|
|
||||||
gp_Vec normToWhere = GetNormal( TopoDS::Face(Exp_aWhere.Current()), aWhereDistance);
|
|
||||||
if ( normToWhat * normToWhere < 0 )
|
|
||||||
normToWhat.Reverse();
|
|
||||||
isFound = ( normToWhat.Angle( normToWhere ) < angleTol );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( isFound ) {
|
|
||||||
aWhereIndex = aWhereIndices.FindIndex(Exp_aWhere.Current());
|
|
||||||
aModifiedList.Append(aWhereIndex);
|
|
||||||
//aWhere_Mass += tab_aWhere[3];
|
|
||||||
isFound = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//if ( fabs( aWhat_Mass - aWhere_Mass ) <= Tol_Mass )
|
|
||||||
//break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (aModifiedList.Extent() == 0) { // Not found any Results
|
|
||||||
SetErrorCode(NOT_FOUND_ANY);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
aModifiedArray = new TColStd_HArray1OfInteger (1, aModifiedList.Extent());
|
|
||||||
TColStd_ListIteratorOfListOfInteger anIterModif (aModifiedList);
|
|
||||||
for (Standard_Integer imod = 1; anIterModif.More(); anIterModif.Next(), imod++)
|
|
||||||
aModifiedArray->SetValue(imod, anIterModif.Value());
|
|
||||||
|
|
||||||
//Add a new object
|
//Add a new object
|
||||||
aResult = GetEngine()->AddSubShape(theShapeWhere, aModifiedArray);
|
Handle(GEOM_Object) aResult =
|
||||||
|
GetEngine()->AddSubShape(theShapeWhere, aModifiedArray);
|
||||||
|
|
||||||
if (aResult.IsNull()) {
|
if (aResult.IsNull()) {
|
||||||
SetErrorCode("Error in algorithm: result found, but cannot be returned.");
|
SetErrorCode("Error in algorithm: result found, but cannot be returned.");
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -4482,6 +4070,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetInPlaceOld (Handle(GEOM_Objec
|
|||||||
<< theShapeWhere << ", " << theShapeWhat << ", False)";
|
<< theShapeWhere << ", " << theShapeWhat << ", False)";
|
||||||
|
|
||||||
SetErrorCode(OK);
|
SetErrorCode(OK);
|
||||||
|
|
||||||
return aResult;
|
return aResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4507,11 +4096,13 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetInPlaceByHistory
|
|||||||
|
|
||||||
//Fill array of indices
|
//Fill array of indices
|
||||||
TopTools_IndexedMapOfShape aWhereIndices;
|
TopTools_IndexedMapOfShape aWhereIndices;
|
||||||
|
|
||||||
TopExp::MapShapes(aWhere, aWhereIndices);
|
TopExp::MapShapes(aWhere, aWhereIndices);
|
||||||
|
|
||||||
// process shape
|
// process shape
|
||||||
TColStd_ListOfInteger aModifiedList;
|
TopTools_ListOfShape aModifiedList;
|
||||||
bool isFound = GetInPlaceOfShape(aWhereFunction, aWhereIndices, aWhat, aModifiedList);
|
bool isFound = GEOMAlgo_GetInPlaceAPI::GetInPlaceByHistory
|
||||||
|
(aWhereFunction, aWhereIndices, aWhat, aModifiedList);
|
||||||
|
|
||||||
if (!isFound || aModifiedList.Extent() < 1) {
|
if (!isFound || aModifiedList.Extent() < 1) {
|
||||||
SetErrorCode("Error: No history found for the sought shape or its sub-shapes.");
|
SetErrorCode("Error: No history found for the sought shape or its sub-shapes.");
|
||||||
@ -4519,13 +4110,13 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetInPlaceByHistory
|
|||||||
}
|
}
|
||||||
|
|
||||||
Standard_Integer nbFound = aModifiedList.Extent();
|
Standard_Integer nbFound = aModifiedList.Extent();
|
||||||
TColStd_ListIteratorOfListOfInteger anIterModif (aModifiedList);
|
TopTools_ListIteratorOfListOfShape anIterModif (aModifiedList);
|
||||||
if ( nbFound > 1 )
|
if ( nbFound > 1 )
|
||||||
{
|
{
|
||||||
// remove sub-shapes inappropriate for group creation
|
// remove sub-shapes inappropriate for group creation
|
||||||
TopAbs_ShapeEnum subType = TopAbs_SHAPE;
|
TopAbs_ShapeEnum subType = TopAbs_SHAPE;
|
||||||
while ( anIterModif.More() ) {
|
while ( anIterModif.More() ) {
|
||||||
TopAbs_ShapeEnum type = aWhereIndices( anIterModif.Value() ).ShapeType();
|
TopAbs_ShapeEnum type = anIterModif.Value().ShapeType();
|
||||||
bool okForGroup = ( type == TopAbs_VERTEX || type == TopAbs_EDGE ||
|
bool okForGroup = ( type == TopAbs_VERTEX || type == TopAbs_EDGE ||
|
||||||
type == TopAbs_FACE || type == TopAbs_SOLID );
|
type == TopAbs_FACE || type == TopAbs_SOLID );
|
||||||
if ( okForGroup ) {
|
if ( okForGroup ) {
|
||||||
@ -4550,7 +4141,8 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetInPlaceByHistory
|
|||||||
new TColStd_HArray1OfInteger( 1, nbFound );
|
new TColStd_HArray1OfInteger( 1, nbFound );
|
||||||
anIterModif.Initialize(aModifiedList);
|
anIterModif.Initialize(aModifiedList);
|
||||||
for (Standard_Integer imod = 1; anIterModif.More(); anIterModif.Next(), imod++)
|
for (Standard_Integer imod = 1; anIterModif.More(); anIterModif.Next(), imod++)
|
||||||
aModifiedArray->SetValue(imod, anIterModif.Value());
|
aModifiedArray->SetValue
|
||||||
|
(imod, aWhereIndices.FindIndex(anIterModif.Value()));
|
||||||
|
|
||||||
//Add a new object
|
//Add a new object
|
||||||
Handle(GEOM_Object) aResult = GetEngine()->AddSubShape(theShapeWhere, aModifiedArray);
|
Handle(GEOM_Object) aResult = GetEngine()->AddSubShape(theShapeWhere, aModifiedArray);
|
||||||
|
@ -34,22 +34,17 @@
|
|||||||
|
|
||||||
#include "GEOMAlgo_State.hxx"
|
#include "GEOMAlgo_State.hxx"
|
||||||
|
|
||||||
#include <TopoDS_Shape.hxx>
|
|
||||||
#include <TopTools_ListOfShape.hxx>
|
|
||||||
#include <NCollection_DataMap.hxx>
|
|
||||||
#include <TColStd_HSequenceOfTransient.hxx>
|
#include <TColStd_HSequenceOfTransient.hxx>
|
||||||
#include <TColStd_HSequenceOfInteger.hxx>
|
#include <TColStd_HSequenceOfInteger.hxx>
|
||||||
|
|
||||||
#include <Handle_Geom_Surface.hxx>
|
#include <Geom_Surface.hxx>
|
||||||
|
|
||||||
#include <gp_Pnt.hxx>
|
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <functional>
|
|
||||||
|
|
||||||
class GEOM_Engine;
|
class GEOM_Engine;
|
||||||
class Handle(GEOM_Object);
|
class Handle(GEOM_Object);
|
||||||
class Handle(TColStd_HArray1OfInteger);
|
class Handle(TColStd_HArray1OfInteger);
|
||||||
|
class TopoDS_Shape;
|
||||||
|
|
||||||
class GEOMImpl_IShapesOperations : public GEOM_IOperations
|
class GEOMImpl_IShapesOperations : public GEOM_IOperations
|
||||||
{
|
{
|
||||||
@ -304,8 +299,6 @@ class GEOMImpl_IShapesOperations : public GEOM_IOperations
|
|||||||
Handle(GEOM_Object) theCenter,
|
Handle(GEOM_Object) theCenter,
|
||||||
const Standard_Real theRadius);
|
const Standard_Real theRadius);
|
||||||
|
|
||||||
void GetShapeProperties(const TopoDS_Shape aShape, Standard_Real propertiesArray[], gp_Pnt & aPnt);
|
|
||||||
|
|
||||||
Standard_EXPORT Handle(GEOM_Object) GetInPlace (Handle(GEOM_Object) theShapeWhere,
|
Standard_EXPORT Handle(GEOM_Object) GetInPlace (Handle(GEOM_Object) theShapeWhere,
|
||||||
Handle(GEOM_Object) theShapeWhat);
|
Handle(GEOM_Object) theShapeWhat);
|
||||||
|
|
||||||
|
137
src/GEOMImpl/GEOMImpl_ITransferData.cxx
Normal file
137
src/GEOMImpl/GEOMImpl_ITransferData.cxx
Normal file
@ -0,0 +1,137 @@
|
|||||||
|
// Copyright (C) 2007-2014 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, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// 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
|
||||||
|
//
|
||||||
|
|
||||||
|
//NOTE: This is an intreface to a function for the Transfer Data functionality.
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
#include "GEOMImpl_ITransferData.hxx"
|
||||||
|
|
||||||
|
#include <TDataStd_Comment.hxx>
|
||||||
|
#include <TDataStd_Name.hxx>
|
||||||
|
#include <TDF_ChildIDIterator.hxx>
|
||||||
|
#include <TNaming_Builder.hxx>
|
||||||
|
#include <TNaming_NamedShape.hxx>
|
||||||
|
|
||||||
|
|
||||||
|
//=============================================================================
|
||||||
|
/*!
|
||||||
|
* SetName
|
||||||
|
*/
|
||||||
|
//=============================================================================
|
||||||
|
void GEOMImpl_ITransferData::SetStringData
|
||||||
|
(const TopoDS_Shape &theSubShape,
|
||||||
|
const TCollection_AsciiString &theData,
|
||||||
|
const Standard_Boolean IsName)
|
||||||
|
{
|
||||||
|
TDF_Label aLabel;
|
||||||
|
TDF_ChildIDIterator anIt
|
||||||
|
(_func->GetNamingEntry(), TDataStd_Name::GetID(), Standard_True);
|
||||||
|
|
||||||
|
for (; anIt.More(); anIt.Next()) {
|
||||||
|
Handle(TDataStd_Name) aNameAttr =
|
||||||
|
Handle(TDataStd_Name)::DownCast(anIt.Value());
|
||||||
|
|
||||||
|
if (aNameAttr.IsNull()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
TDF_Label aLab = aNameAttr->Label();
|
||||||
|
Handle(TNaming_NamedShape) aShAttr;
|
||||||
|
|
||||||
|
if (aLab.FindAttribute(TNaming_NamedShape::GetID(), aShAttr) &&
|
||||||
|
aShAttr->Get().IsEqual(theSubShape)) {
|
||||||
|
aLabel = aLab;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (aLabel.IsNull()) {
|
||||||
|
TDF_TagSource aTag;
|
||||||
|
|
||||||
|
aLabel = aTag.NewChild(_func->GetNamingEntry());
|
||||||
|
|
||||||
|
TNaming_Builder aTnBuild (aLabel);
|
||||||
|
|
||||||
|
aTnBuild.Generated(theSubShape);
|
||||||
|
}
|
||||||
|
|
||||||
|
// set a name or a material
|
||||||
|
TCollection_ExtendedString aDataExt(theData);
|
||||||
|
|
||||||
|
if (IsName) {
|
||||||
|
TDataStd_Name::Set(aLabel, aDataExt);
|
||||||
|
} else {
|
||||||
|
TDataStd_Comment::Set(aLabel, aDataExt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//=============================================================================
|
||||||
|
/*!
|
||||||
|
* GetStringData
|
||||||
|
*/
|
||||||
|
//=============================================================================
|
||||||
|
TCollection_AsciiString GEOMImpl_ITransferData::GetStringData
|
||||||
|
(const TopoDS_Shape &theSubShape,
|
||||||
|
const Standard_Boolean IsName)
|
||||||
|
{
|
||||||
|
// check all named shapes using iterator
|
||||||
|
TCollection_AsciiString aResult;
|
||||||
|
TDF_ChildIDIterator anIt
|
||||||
|
(_func->GetNamingEntry(), TNaming_NamedShape::GetID(), Standard_True);
|
||||||
|
|
||||||
|
for (; anIt.More(); anIt.Next()) {
|
||||||
|
Handle(TNaming_NamedShape) aShAttr =
|
||||||
|
Handle(TNaming_NamedShape)::DownCast(anIt.Value());
|
||||||
|
|
||||||
|
if (aShAttr.IsNull()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (aShAttr->Get().IsEqual(theSubShape)) {
|
||||||
|
TDF_Label aLabel = aShAttr->Label();
|
||||||
|
Standard_Boolean isFound = Standard_False;
|
||||||
|
|
||||||
|
if (IsName) {
|
||||||
|
Handle(TDataStd_Name) aString;
|
||||||
|
|
||||||
|
if(aLabel.FindAttribute(TDataStd_Name::GetID(), aString)) {
|
||||||
|
aResult = TCollection_AsciiString(aString->Get());
|
||||||
|
isFound = Standard_True;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Handle(TDataStd_Comment) aString;
|
||||||
|
|
||||||
|
if(aLabel.FindAttribute(TDataStd_Comment::GetID(), aString)) {
|
||||||
|
aResult = TCollection_AsciiString(aString->Get());
|
||||||
|
isFound = Standard_True;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isFound) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return aResult;
|
||||||
|
}
|
114
src/GEOMImpl/GEOMImpl_ITransferData.hxx
Normal file
114
src/GEOMImpl/GEOMImpl_ITransferData.hxx
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
// Copyright (C) 2007-2014 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, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// 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
|
||||||
|
//
|
||||||
|
|
||||||
|
//NOTE: This is an intreface to a function for the Transfer Data functionality.
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef _GEOMImpl_ITransferData_HXX_
|
||||||
|
#define _GEOMImpl_ITransferData_HXX_
|
||||||
|
|
||||||
|
|
||||||
|
#include "GEOM_GEOMImpl.hxx"
|
||||||
|
#include "GEOM_Function.hxx"
|
||||||
|
|
||||||
|
#include <TColStd_HArray1OfInteger.hxx>
|
||||||
|
|
||||||
|
|
||||||
|
#define TD_ARG_REF1 1
|
||||||
|
#define TD_ARG_REF2 2
|
||||||
|
#define TD_ARG_METHOD 3
|
||||||
|
#define TD_ARG_DATUM_NAME 4
|
||||||
|
#define TD_ARG_DATUM_MAX_VALUE 5
|
||||||
|
#define TD_ARG_DATUM_VALUE 6
|
||||||
|
|
||||||
|
class GEOMImpl_ITransferData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
GEOMImpl_ITransferData(const Handle(GEOM_Function) &theFunction)
|
||||||
|
: _func(theFunction) {}
|
||||||
|
|
||||||
|
void SetRef1(const Handle(GEOM_Function) &theRefPoint1)
|
||||||
|
{ _func->SetReference(TD_ARG_REF1, theRefPoint1); }
|
||||||
|
|
||||||
|
Handle(GEOM_Function) GetRef1() { return _func->GetReference(TD_ARG_REF1); }
|
||||||
|
|
||||||
|
void SetRef2(const Handle(GEOM_Function) &theRefPoint2)
|
||||||
|
{ _func->SetReference(TD_ARG_REF2, theRefPoint2); }
|
||||||
|
|
||||||
|
Handle(GEOM_Function) GetRef2() { return _func->GetReference(TD_ARG_REF2); }
|
||||||
|
|
||||||
|
void SetFindMethod(const int theFindMethod)
|
||||||
|
{ _func->SetInteger(TD_ARG_METHOD, theFindMethod); }
|
||||||
|
|
||||||
|
int GetFindMethod() { return _func->GetInteger(TD_ARG_METHOD); }
|
||||||
|
|
||||||
|
void SetDatumName(const Handle(TColStd_HArray1OfExtendedString) &theDatumName)
|
||||||
|
{ _func->SetStringArray(TD_ARG_DATUM_NAME, theDatumName); }
|
||||||
|
|
||||||
|
Handle(TColStd_HArray1OfExtendedString) GetDatumName()
|
||||||
|
{ return _func->GetStringArray(TD_ARG_DATUM_NAME); }
|
||||||
|
|
||||||
|
void SetDatumMaxVal(const Handle(TColStd_HArray1OfInteger) &theDatumMaxVal)
|
||||||
|
{ _func->SetIntegerArray(TD_ARG_DATUM_MAX_VALUE, theDatumMaxVal); }
|
||||||
|
|
||||||
|
Handle(TColStd_HArray1OfInteger) GetDatumMaxVal()
|
||||||
|
{ return _func->GetIntegerArray(TD_ARG_DATUM_MAX_VALUE); }
|
||||||
|
|
||||||
|
void SetDatumVal(const Handle(TColStd_HArray1OfInteger) &theDatumVal)
|
||||||
|
{ _func->SetIntegerArray(TD_ARG_DATUM_VALUE, theDatumVal); }
|
||||||
|
|
||||||
|
Handle(TColStd_HArray1OfInteger) GetDatumVal()
|
||||||
|
{ return _func->GetIntegerArray(TD_ARG_DATUM_VALUE); }
|
||||||
|
|
||||||
|
GEOMIMPL_EXPORT void SetName(const TopoDS_Shape &theSubShape,
|
||||||
|
const TCollection_AsciiString &theName)
|
||||||
|
{ SetStringData(theSubShape, theName, Standard_True); }
|
||||||
|
|
||||||
|
GEOMIMPL_EXPORT TCollection_AsciiString GetName
|
||||||
|
(const TopoDS_Shape &theSubShape)
|
||||||
|
{ return GetStringData(theSubShape, Standard_True); }
|
||||||
|
|
||||||
|
GEOMIMPL_EXPORT void SetMaterial(const TopoDS_Shape &theSubShape,
|
||||||
|
const TCollection_AsciiString &theName)
|
||||||
|
{ SetStringData(theSubShape, theName, Standard_False); }
|
||||||
|
|
||||||
|
GEOMIMPL_EXPORT TCollection_AsciiString GetMaterial
|
||||||
|
(const TopoDS_Shape &theSubShape)
|
||||||
|
{ return GetStringData(theSubShape, Standard_False); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
TCollection_AsciiString GetStringData(const TopoDS_Shape &theSubShape,
|
||||||
|
const Standard_Boolean IsName);
|
||||||
|
|
||||||
|
void SetStringData(const TopoDS_Shape &theSubShape,
|
||||||
|
const TCollection_AsciiString &theData,
|
||||||
|
const Standard_Boolean IsName);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
Handle(GEOM_Function) _func;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -117,10 +117,13 @@
|
|||||||
|
|
||||||
#define GEOM_POLYLINE2D 56
|
#define GEOM_POLYLINE2D 56
|
||||||
|
|
||||||
|
#define GEOM_TRANSFER_DATA 57
|
||||||
|
|
||||||
//GEOM_Function types
|
//GEOM_Function types
|
||||||
|
|
||||||
#define COPY_WITH_REF 1
|
#define COPY_WITH_REF 1
|
||||||
#define COPY_WITHOUT_REF 2
|
#define COPY_WITHOUT_REF 2
|
||||||
|
#define TRANSFER_DATA 3
|
||||||
|
|
||||||
#define IMPORT_SHAPE 1
|
#define IMPORT_SHAPE 1
|
||||||
#define EXPORT_SHAPE 2
|
#define EXPORT_SHAPE 2
|
||||||
@ -379,6 +382,10 @@
|
|||||||
#define USER_TYPE 200 // Base type for GEOM advanced shapes
|
#define USER_TYPE 200 // Base type for GEOM advanced shapes
|
||||||
#define USER_TYPE_EX 1000 // Base type for GEOM plugins
|
#define USER_TYPE_EX 1000 // Base type for GEOM plugins
|
||||||
|
|
||||||
|
// Transfer data method type
|
||||||
|
#define TD_GET_IN_PLACE 1
|
||||||
|
#define TD_GET_IN_PLACE_OLD 2
|
||||||
|
#define TD_GET_IN_PLACE_BY_HISTORY 3
|
||||||
|
|
||||||
// Plugins specified constants
|
// Plugins specified constants
|
||||||
#define PLUGIN_NAME "Plugin Name"
|
#define PLUGIN_NAME "Plugin Name"
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
|
|
||||||
#include "GEOM_Engine.hxx"
|
#include "GEOM_Engine.hxx"
|
||||||
#include "GEOM_BaseObject.hxx"
|
#include "GEOM_BaseObject.hxx"
|
||||||
|
#include "GEOMImpl_Types.hxx"
|
||||||
|
|
||||||
#include <Basics_OCCTVersion.hxx>
|
#include <Basics_OCCTVersion.hxx>
|
||||||
|
|
||||||
@ -259,4 +260,83 @@ GEOM::ListOfLong* GEOM_IInsertOperations_i::GetAllTextures()
|
|||||||
return anIDs._retn();
|
return anIDs._retn();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=============================================================================
|
||||||
|
/*!
|
||||||
|
* TransferData
|
||||||
|
*/
|
||||||
|
//=============================================================================
|
||||||
|
CORBA::Boolean GEOM_IInsertOperations_i::TransferData
|
||||||
|
(GEOM::GEOM_Object_ptr theObjectFrom,
|
||||||
|
GEOM::GEOM_Object_ptr theObjectTo,
|
||||||
|
GEOM::find_shape_method theFindMethod,
|
||||||
|
GEOM::GEOM_IInsertOperations::ListOfTransferDatum_out theResult)
|
||||||
|
{
|
||||||
|
//Set a not done flag
|
||||||
|
GetOperations()->SetNotDone();
|
||||||
|
|
||||||
|
if (CORBA::is_nil(theObjectFrom) || CORBA::is_nil(theObjectTo))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Get the reference shape
|
||||||
|
Handle(GEOM_Object) aShapeFrom = GetObjectImpl(theObjectFrom);
|
||||||
|
Handle(GEOM_Object) aShapeTo = GetObjectImpl(theObjectTo);
|
||||||
|
|
||||||
|
if (aShapeFrom.IsNull() || aShapeTo.IsNull())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isOk = false;
|
||||||
|
std::list<GEOMImpl_IInsertOperations::TransferDatum> aData;
|
||||||
|
int aFindMethod = -1;
|
||||||
|
|
||||||
|
switch (theFindMethod) {
|
||||||
|
case GEOM::FSM_GetInPlace:
|
||||||
|
aFindMethod = TD_GET_IN_PLACE;
|
||||||
|
break;
|
||||||
|
case GEOM::FSM_GetInPlaceByHistory:
|
||||||
|
aFindMethod = TD_GET_IN_PLACE_BY_HISTORY;
|
||||||
|
break;
|
||||||
|
case GEOM::FSM_GetInPlace_Old:
|
||||||
|
aFindMethod = TD_GET_IN_PLACE_OLD;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transfer data.
|
||||||
|
if (aFindMethod > 0) {
|
||||||
|
isOk = GetOperations()->TransferData
|
||||||
|
(aShapeFrom, aShapeTo, aFindMethod, aData);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isOk) {
|
||||||
|
// Copy results.
|
||||||
|
const int aNbDatum = aData.size();
|
||||||
|
GEOM::GEOM_IInsertOperations::ListOfTransferDatum_var aResult =
|
||||||
|
new GEOM::GEOM_IInsertOperations::ListOfTransferDatum;
|
||||||
|
|
||||||
|
aResult->length(aNbDatum);
|
||||||
|
|
||||||
|
// fill the local CORBA array with values from lists
|
||||||
|
std::list<GEOMImpl_IInsertOperations::TransferDatum>::const_iterator
|
||||||
|
anIt = aData.begin();
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
for (; anIt != aData.end(); i++, anIt++) {
|
||||||
|
GEOM::GEOM_IInsertOperations::TransferDatum_var aDatum =
|
||||||
|
new GEOM::GEOM_IInsertOperations::TransferDatum;
|
||||||
|
|
||||||
|
aDatum->myName = CORBA::string_dup(anIt->myName.ToCString());
|
||||||
|
aDatum->myNumber = anIt->myNumber;
|
||||||
|
aDatum->myMaxNumber = anIt->myMaxNumber;
|
||||||
|
aResult[i] = aDatum;
|
||||||
|
}
|
||||||
|
|
||||||
|
theResult = aResult._retn();
|
||||||
|
}
|
||||||
|
|
||||||
|
return isOk;
|
||||||
|
}
|
||||||
|
@ -66,7 +66,13 @@ class GEOM_I_EXPORT GEOM_IInsertOperations_i :
|
|||||||
CORBA::Long& theHeight);
|
CORBA::Long& theHeight);
|
||||||
|
|
||||||
GEOM::ListOfLong* GetAllTextures();
|
GEOM::ListOfLong* GetAllTextures();
|
||||||
|
|
||||||
|
CORBA::Boolean TransferData
|
||||||
|
(GEOM::GEOM_Object_ptr theObjectFrom,
|
||||||
|
GEOM::GEOM_Object_ptr theObjectTo,
|
||||||
|
GEOM::find_shape_method theFindMethod,
|
||||||
|
GEOM::GEOM_IInsertOperations::ListOfTransferDatum_out theResult);
|
||||||
|
|
||||||
::GEOMImpl_IInsertOperations* GetOperations()
|
::GEOMImpl_IInsertOperations* GetOperations()
|
||||||
{ return (::GEOMImpl_IInsertOperations*)GetImpl(); }
|
{ return (::GEOMImpl_IInsertOperations*)GetImpl(); }
|
||||||
};
|
};
|
||||||
|
@ -562,6 +562,18 @@ def TestOtherOperations (geompy, math):
|
|||||||
ind = ind + 1
|
ind = ind + 1
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
# TransferData
|
||||||
|
path = os.getenv("DATA_DIR")
|
||||||
|
fileName = path + "/Shapes/Step/black_and_white.step"
|
||||||
|
blackWhite = geompy.ImportSTEP(fileName)
|
||||||
|
blackWhiteCopy = geompy.MakeCopy(blackWhite[0])
|
||||||
|
subBlackWhite = geompy.SubShapeAll(blackWhiteCopy, GEOM.SOLID)
|
||||||
|
geompy.TransferData(blackWhite[0], blackWhiteCopy)
|
||||||
|
geompy.addToStudy(blackWhite[0], "blackWhite")
|
||||||
|
geompy.addToStudy(blackWhiteCopy, "blackWhiteCopy")
|
||||||
|
geompy.addToStudyInFather( blackWhiteCopy, subBlackWhite[0], "" )
|
||||||
|
geompy.addToStudyInFather( blackWhiteCopy, subBlackWhite[1], "" )
|
||||||
|
|
||||||
# CheckAndImprove
|
# CheckAndImprove
|
||||||
blocksComp = geompy.CheckAndImprove(part)
|
blocksComp = geompy.CheckAndImprove(part)
|
||||||
|
|
||||||
|
40
src/GEOM_SWIG/geomBuilder.py
Normal file → Executable file
40
src/GEOM_SWIG/geomBuilder.py
Normal file → Executable file
@ -12934,6 +12934,46 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
|
|||||||
RaiseIfFailed("AddTexture", self.InsertOp)
|
RaiseIfFailed("AddTexture", self.InsertOp)
|
||||||
return ID
|
return ID
|
||||||
|
|
||||||
|
## Transfer not topological data from one GEOM object to another.
|
||||||
|
#
|
||||||
|
# @param theObjectFrom the source object of non-topological data
|
||||||
|
# @param theObjectTo the destination object of non-topological data
|
||||||
|
# @param theFindMethod method to search sub-shapes of theObjectFrom
|
||||||
|
# in shape theObjectTo. Possible values are: GEOM.FSM_GetInPlace,
|
||||||
|
# GEOM.FSM_GetInPlaceByHistory and GEOM.FSM_GetInPlace_Old.
|
||||||
|
# Other values of GEOM.find_shape_method are not supported.
|
||||||
|
#
|
||||||
|
# @return True in case of success; False otherwise.
|
||||||
|
#
|
||||||
|
# @ingroup l1_geomBuilder_auxiliary
|
||||||
|
#
|
||||||
|
# @ref swig_TransferData "Example"
|
||||||
|
@ManageTransactions("InsertOp")
|
||||||
|
def TransferData(self, theObjectFrom, theObjectTo,
|
||||||
|
theFindMethod=GEOM.FSM_GetInPlace):
|
||||||
|
"""
|
||||||
|
Transfer not topological data from one GEOM object to another.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
theObjectFrom the source object of non-topological data
|
||||||
|
theObjectTo the destination object of non-topological data
|
||||||
|
theFindMethod method to search sub-shapes of theObjectFrom
|
||||||
|
in shape theObjectTo. Possible values are:
|
||||||
|
GEOM.FSM_GetInPlace, GEOM.FSM_GetInPlaceByHistory
|
||||||
|
and GEOM.FSM_GetInPlace_Old. Other values of
|
||||||
|
GEOM.find_shape_method are not supported.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
True in case of success; False otherwise.
|
||||||
|
|
||||||
|
# Example: see GEOM_TestOthers.py
|
||||||
|
"""
|
||||||
|
# Example: see GEOM_TestAll.py
|
||||||
|
isOk = self.InsertOp.TransferData(theObjectFrom,
|
||||||
|
theObjectTo, theFindMethod)
|
||||||
|
RaiseIfFailed("TransferData", self.InsertOp)
|
||||||
|
return isOk
|
||||||
|
|
||||||
## Creates a new folder object. It is a container for any GEOM objects.
|
## Creates a new folder object. It is a container for any GEOM objects.
|
||||||
# @param Name name of the container
|
# @param Name name of the container
|
||||||
# @param Father parent object. If None,
|
# @param Father parent object. If None,
|
||||||
|
@ -76,6 +76,7 @@ SET(OperationGUI_HEADERS
|
|||||||
OperationGUI_GetSharedShapesDlg.h
|
OperationGUI_GetSharedShapesDlg.h
|
||||||
OperationGUI_ExtrudedFeatureDlg.h
|
OperationGUI_ExtrudedFeatureDlg.h
|
||||||
OperationGUI_ClippingDlg.h
|
OperationGUI_ClippingDlg.h
|
||||||
|
OperationGUI_TransferDataDlg.h
|
||||||
)
|
)
|
||||||
|
|
||||||
# header files / to be processed by moc
|
# header files / to be processed by moc
|
||||||
@ -89,6 +90,7 @@ SET(_moc_HEADERS
|
|||||||
OperationGUI_GetSharedShapesDlg.h
|
OperationGUI_GetSharedShapesDlg.h
|
||||||
OperationGUI_ExtrudedFeatureDlg.h
|
OperationGUI_ExtrudedFeatureDlg.h
|
||||||
OperationGUI_ClippingDlg.h
|
OperationGUI_ClippingDlg.h
|
||||||
|
OperationGUI_TransferDataDlg.h
|
||||||
)
|
)
|
||||||
|
|
||||||
# header files / uic wrappings
|
# header files / uic wrappings
|
||||||
@ -110,6 +112,7 @@ SET(OperationGUI_SOURCES
|
|||||||
OperationGUI_ChamferDlg.cxx
|
OperationGUI_ChamferDlg.cxx
|
||||||
OperationGUI_ExtrudedFeatureDlg.cxx
|
OperationGUI_ExtrudedFeatureDlg.cxx
|
||||||
OperationGUI_ClippingDlg.cxx
|
OperationGUI_ClippingDlg.cxx
|
||||||
|
OperationGUI_TransferDataDlg.cxx
|
||||||
${_moc_SOURCES}
|
${_moc_SOURCES}
|
||||||
${_uic_files}
|
${_uic_files}
|
||||||
)
|
)
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
#include "OperationGUI_GetShapesOnShapeDlg.h"
|
#include "OperationGUI_GetShapesOnShapeDlg.h"
|
||||||
#include "OperationGUI_GetSharedShapesDlg.h"
|
#include "OperationGUI_GetSharedShapesDlg.h"
|
||||||
#include "OperationGUI_ExtrudedFeatureDlg.h" // Methods EXTRUDED BOSS / CUT
|
#include "OperationGUI_ExtrudedFeatureDlg.h" // Methods EXTRUDED BOSS / CUT
|
||||||
|
#include "OperationGUI_TransferDataDlg.h"
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
// function : OperationGUI()
|
// function : OperationGUI()
|
||||||
@ -81,6 +82,7 @@ bool OperationGUI::OnGUIEvent (int theCommandID, SUIT_Desktop* parent)
|
|||||||
case GEOMOp::OpExtrudedCut: (new OperationGUI_ExtrudedFeatureDlg (CUT, getGeometryGUI(), parent))->show(); break;
|
case GEOMOp::OpExtrudedCut: (new OperationGUI_ExtrudedFeatureDlg (CUT, getGeometryGUI(), parent))->show(); break;
|
||||||
case GEOMOp::OpFillet1d: (new OperationGUI_Fillet1d2dDlg (getGeometryGUI(), parent, true))->show(); break;
|
case GEOMOp::OpFillet1d: (new OperationGUI_Fillet1d2dDlg (getGeometryGUI(), parent, true))->show(); break;
|
||||||
case GEOMOp::OpFillet2d: (new OperationGUI_Fillet1d2dDlg (getGeometryGUI(), parent, false))->show(); break;
|
case GEOMOp::OpFillet2d: (new OperationGUI_Fillet1d2dDlg (getGeometryGUI(), parent, false))->show(); break;
|
||||||
|
case GEOMOp::OpTransferData: (new OperationGUI_TransferDataDlg (getGeometryGUI(), parent))->show(); break;
|
||||||
default:
|
default:
|
||||||
app->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID));
|
app->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID));
|
||||||
}
|
}
|
||||||
|
331
src/OperationGUI/OperationGUI_TransferDataDlg.cxx
Executable file
331
src/OperationGUI/OperationGUI_TransferDataDlg.cxx
Executable file
@ -0,0 +1,331 @@
|
|||||||
|
// Copyright (C) 2007-2014 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, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// 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 "OperationGUI_TransferDataDlg.h"
|
||||||
|
|
||||||
|
#include <DlgRef.h>
|
||||||
|
#include <GeometryGUI.h>
|
||||||
|
#include <GEOMBase.h>
|
||||||
|
|
||||||
|
#include <SUIT_Desktop.h>
|
||||||
|
#include <SUIT_MessageBox.h>
|
||||||
|
#include <SUIT_Session.h>
|
||||||
|
#include <SUIT_ResourceMgr.h>
|
||||||
|
#include <SalomeApp_Application.h>
|
||||||
|
#include <LightApp_SelectionMgr.h>
|
||||||
|
|
||||||
|
//==============================================================================
|
||||||
|
// class : OperationGUI_TransferDataDlg()
|
||||||
|
// purpose : Constructs a OperationGUI_TransferDataDlg which is a child of
|
||||||
|
// 'parent'.
|
||||||
|
//=================================================================================
|
||||||
|
OperationGUI_TransferDataDlg::OperationGUI_TransferDataDlg (GeometryGUI* theGeometryGUI,
|
||||||
|
QWidget* parent)
|
||||||
|
: GEOMBase_Skeleton(theGeometryGUI, parent, false),
|
||||||
|
myGroup(NULL)
|
||||||
|
{
|
||||||
|
SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr();
|
||||||
|
QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_TRANSFER_DATA")));
|
||||||
|
QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
|
||||||
|
|
||||||
|
setWindowTitle(tr("GEOM_TRANSFER_DATA_TITLE"));
|
||||||
|
|
||||||
|
/***************************************************************/
|
||||||
|
mainFrame()->GroupConstructors->setTitle(tr("GEOM_TRANSFER_DATA"));
|
||||||
|
mainFrame()->RadioButton1->setIcon(image0);
|
||||||
|
mainFrame()->RadioButton2->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
mainFrame()->RadioButton2->close();
|
||||||
|
mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
mainFrame()->RadioButton3->close();
|
||||||
|
|
||||||
|
mainFrame()->GroupBoxName->hide();
|
||||||
|
|
||||||
|
myGroup = new DlgRef_2Sel1List(centralWidget());
|
||||||
|
myGroup->GroupBox1->setTitle(tr("GEOM_PARAMETERS"));
|
||||||
|
myGroup->TextLabel1->setText(tr("GEOM_TRANSFER_DATA_FROM"));
|
||||||
|
myGroup->TextLabel2->setText(tr("GEOM_TRANSFER_DATA_TO"));
|
||||||
|
myGroup->TextLabel3->setText(tr("GEOM_TRANSFER_DATA_METHOD"));
|
||||||
|
myGroup->PushButton1->setIcon(image1);
|
||||||
|
myGroup->PushButton2->setIcon(image1);
|
||||||
|
myGroup->LineEdit1->setReadOnly(true);
|
||||||
|
myGroup->LineEdit2->setReadOnly(true);
|
||||||
|
|
||||||
|
QVBoxLayout* layout = new QVBoxLayout(centralWidget());
|
||||||
|
layout->setMargin(0); layout->setSpacing(6);
|
||||||
|
layout->addWidget(myGroup);
|
||||||
|
/***************************************************************/
|
||||||
|
|
||||||
|
setHelpFileName("transfer_data_page.html");
|
||||||
|
|
||||||
|
Init();
|
||||||
|
}
|
||||||
|
|
||||||
|
//=================================================================================
|
||||||
|
// function : ~OperationGUI_TransferDataDlg
|
||||||
|
// purpose : Destroys the object and frees any allocated resources
|
||||||
|
//=================================================================================
|
||||||
|
OperationGUI_TransferDataDlg::~OperationGUI_TransferDataDlg()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//=================================================================================
|
||||||
|
// function : Init()
|
||||||
|
// purpose :
|
||||||
|
//=================================================================================
|
||||||
|
void OperationGUI_TransferDataDlg::Init()
|
||||||
|
{
|
||||||
|
// type for detection
|
||||||
|
myGroup->ComboBox1->addItem(tr("GEOM_TD_METHOD_GETINPLACE"));
|
||||||
|
myGroup->ComboBox1->addItem(tr("GEOM_TD_METHOD_GETINPLACE_OLD"));
|
||||||
|
myGroup->ComboBox1->addItem(tr("GEOM_TD_METHOD_GETINPLACE_HISTORY"));
|
||||||
|
|
||||||
|
myGroup->LineEdit1->clear();
|
||||||
|
myGroup->LineEdit2->clear();
|
||||||
|
myObject1.nullify();
|
||||||
|
myObject2.nullify();
|
||||||
|
|
||||||
|
// signals and slots connections
|
||||||
|
connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
|
||||||
|
connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
|
||||||
|
|
||||||
|
connect(myGroup->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
|
||||||
|
connect(myGroup->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
|
||||||
|
|
||||||
|
connect(myGroup->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
|
||||||
|
connect(myGroup->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
|
||||||
|
|
||||||
|
connect(myGroup->ComboBox1, SIGNAL(activated(int)), this, SLOT(ComboTextChanged()));
|
||||||
|
|
||||||
|
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
|
||||||
|
this, SLOT(SelectionIntoArgument()));
|
||||||
|
|
||||||
|
myGroup->TextLabel3->show();
|
||||||
|
myGroup->ComboBox1->show();
|
||||||
|
myGroup->ComboBox1->setCurrentIndex(0);
|
||||||
|
|
||||||
|
globalSelection(GEOM_ALLSHAPES);
|
||||||
|
|
||||||
|
myGroup->PushButton1->click();
|
||||||
|
SelectionIntoArgument();
|
||||||
|
resize(100,100);
|
||||||
|
}
|
||||||
|
|
||||||
|
//=================================================================================
|
||||||
|
// function : ClickOnOk()
|
||||||
|
// purpose :
|
||||||
|
//=================================================================================
|
||||||
|
void OperationGUI_TransferDataDlg::ClickOnOk()
|
||||||
|
{
|
||||||
|
setIsApplyAndClose( true );
|
||||||
|
if (ClickOnApply())
|
||||||
|
ClickOnCancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
//=================================================================================
|
||||||
|
// function : ClickOnApply()
|
||||||
|
// purpose :
|
||||||
|
//=================================================================================
|
||||||
|
bool OperationGUI_TransferDataDlg::ClickOnApply()
|
||||||
|
{
|
||||||
|
if (!onAccept(false))
|
||||||
|
return false;
|
||||||
|
// activate first line edit
|
||||||
|
myGroup->PushButton1->click();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=================================================================================
|
||||||
|
// function : SelectionIntoArgument()
|
||||||
|
// purpose : Called when selection is changed or on dialog initialization or activation
|
||||||
|
//=================================================================================
|
||||||
|
void OperationGUI_TransferDataDlg::SelectionIntoArgument()
|
||||||
|
{
|
||||||
|
GEOM::GeomObjPtr aSelectedObject = getSelected(TopAbs_SHAPE);
|
||||||
|
|
||||||
|
if (aSelectedObject) {
|
||||||
|
myEditCurrentArgument->setText(GEOMBase::GetName(aSelectedObject.get()));
|
||||||
|
|
||||||
|
if (myEditCurrentArgument == myGroup->LineEdit1) {
|
||||||
|
myObject1 = aSelectedObject;
|
||||||
|
|
||||||
|
if (!myObject2) {
|
||||||
|
myGroup->PushButton2->click();
|
||||||
|
}
|
||||||
|
} else if (myEditCurrentArgument == myGroup->LineEdit2) {
|
||||||
|
myObject2 = aSelectedObject;
|
||||||
|
|
||||||
|
if (!myObject1) {
|
||||||
|
myGroup->PushButton1->click();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
myEditCurrentArgument->setText("");
|
||||||
|
|
||||||
|
if (myEditCurrentArgument == myGroup->LineEdit1) {
|
||||||
|
myObject1.nullify();
|
||||||
|
} else if (myEditCurrentArgument == myGroup->LineEdit2) {
|
||||||
|
myObject2.nullify();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//=================================================================================
|
||||||
|
// function : SetEditCurrentArgument()
|
||||||
|
// purpose :
|
||||||
|
//=================================================================================
|
||||||
|
void OperationGUI_TransferDataDlg::SetEditCurrentArgument()
|
||||||
|
{
|
||||||
|
QPushButton* send = (QPushButton*)sender();
|
||||||
|
|
||||||
|
if (send == myGroup->PushButton1) {
|
||||||
|
myEditCurrentArgument = myGroup->LineEdit1;
|
||||||
|
|
||||||
|
myGroup->PushButton2->setDown(false);
|
||||||
|
myGroup->LineEdit2->setEnabled(false);
|
||||||
|
}
|
||||||
|
else if (send == myGroup->PushButton2) {
|
||||||
|
myEditCurrentArgument = myGroup->LineEdit2;
|
||||||
|
|
||||||
|
myGroup->PushButton1->setDown(false);
|
||||||
|
myGroup->LineEdit1->setEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// enable line edit
|
||||||
|
myEditCurrentArgument->setEnabled(true);
|
||||||
|
myEditCurrentArgument->setFocus();
|
||||||
|
// after setFocus(), because it will be setDown(false) when loses focus
|
||||||
|
send->setDown(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
//=================================================================================
|
||||||
|
// function : LineEditReturnPressed()
|
||||||
|
// purpose :
|
||||||
|
//=================================================================================
|
||||||
|
void OperationGUI_TransferDataDlg::LineEditReturnPressed()
|
||||||
|
{
|
||||||
|
QLineEdit* send = (QLineEdit*)sender();
|
||||||
|
if (send == myGroup->LineEdit1 || send == myGroup->LineEdit2)
|
||||||
|
{
|
||||||
|
myEditCurrentArgument = send;
|
||||||
|
GEOMBase_Skeleton::LineEditReturnPressed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//=================================================================================
|
||||||
|
// function : ActivateThisDialog()
|
||||||
|
// purpose :
|
||||||
|
//=================================================================================
|
||||||
|
void OperationGUI_TransferDataDlg::ActivateThisDialog()
|
||||||
|
{
|
||||||
|
GEOMBase_Skeleton::ActivateThisDialog();
|
||||||
|
globalSelection(GEOM_ALLSHAPES);
|
||||||
|
connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
|
||||||
|
this, SLOT( SelectionIntoArgument() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
//=================================================================================
|
||||||
|
// function : enterEvent()
|
||||||
|
// purpose : when mouse enter onto the QWidget
|
||||||
|
//=================================================================================
|
||||||
|
void OperationGUI_TransferDataDlg::enterEvent (QEvent*)
|
||||||
|
{
|
||||||
|
if (!mainFrame()->GroupConstructors->isEnabled())
|
||||||
|
ActivateThisDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
//=================================================================================
|
||||||
|
// function : createOperation
|
||||||
|
// purpose :
|
||||||
|
//=================================================================================
|
||||||
|
GEOM::GEOM_IOperations_ptr OperationGUI_TransferDataDlg::createOperation()
|
||||||
|
{
|
||||||
|
return getGeomEngine()->GetIInsertOperations(getStudyId());
|
||||||
|
}
|
||||||
|
|
||||||
|
//=================================================================================
|
||||||
|
// function : isValid
|
||||||
|
// purpose :
|
||||||
|
//=================================================================================
|
||||||
|
bool OperationGUI_TransferDataDlg::isValid(QString&)
|
||||||
|
{
|
||||||
|
return myObject1 && myObject2;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=================================================================================
|
||||||
|
// function : execute
|
||||||
|
// purpose :
|
||||||
|
//=================================================================================
|
||||||
|
bool OperationGUI_TransferDataDlg::execute (ObjectList& objects)
|
||||||
|
{
|
||||||
|
const int aLimit = myGroup->ComboBox1->currentIndex();
|
||||||
|
GEOM::find_shape_method aMethod;
|
||||||
|
|
||||||
|
switch (aLimit)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
aMethod = GEOM::FSM_GetInPlace;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
aMethod = GEOM::FSM_GetInPlace_Old;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
default:
|
||||||
|
aMethod = GEOM::FSM_GetInPlaceByHistory;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
GEOM::GEOM_IInsertOperations_var anOper =
|
||||||
|
GEOM::GEOM_IInsertOperations::_narrow(getOperation());
|
||||||
|
GEOM::GEOM_IInsertOperations::ListOfTransferDatum_var aResult;
|
||||||
|
|
||||||
|
bool isOK = anOper->TransferData
|
||||||
|
(myObject1.get(), myObject2.get(), aMethod, aResult);
|
||||||
|
|
||||||
|
if (isOK) {
|
||||||
|
// Construct info message.
|
||||||
|
QString aMsg;
|
||||||
|
int aNbTypes = aResult->length();
|
||||||
|
|
||||||
|
if (aNbTypes == 0) {
|
||||||
|
aMsg = tr("GEOM_TRANSFER_DATA_NOT_COPIED");
|
||||||
|
} else {
|
||||||
|
aMsg = tr("GEOM_TRANSFER_DATA_COPIED");
|
||||||
|
aMsg += "\n";
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < aNbTypes; i++ ) {
|
||||||
|
if (i > 0) {
|
||||||
|
aMsg += "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
aMsg += tr(aResult[i].myName).
|
||||||
|
arg(aResult[i].myNumber).arg(aResult[i].myMaxNumber);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show info message.
|
||||||
|
SUIT_MessageBox::information
|
||||||
|
(SUIT_Session::session()->activeApplication()->desktop(),
|
||||||
|
tr("GEOM_TRANSFER_DATA_INFO"), aMsg, tr("BUT_OK"));
|
||||||
|
|
||||||
|
objects.push_back(myObject2.copy());
|
||||||
|
}
|
||||||
|
|
||||||
|
return isOK;
|
||||||
|
}
|
68
src/OperationGUI/OperationGUI_TransferDataDlg.h
Normal file
68
src/OperationGUI/OperationGUI_TransferDataDlg.h
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
// Copyright (C) 2007-2014 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, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// 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 OPERATIONGUI_TRANSFERDATADLG_H
|
||||||
|
#define OPERATIONGUI_TRANSFERDATADLG_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <GEOMBase_Skeleton.h>
|
||||||
|
|
||||||
|
class DlgRef_2Sel1List;
|
||||||
|
|
||||||
|
//=================================================================================
|
||||||
|
// class : OperationGUI_TransferDataDlg
|
||||||
|
// purpose :
|
||||||
|
//=================================================================================
|
||||||
|
class OperationGUI_TransferDataDlg : public GEOMBase_Skeleton
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
OperationGUI_TransferDataDlg
|
||||||
|
( GeometryGUI* theGeometryGUI, QWidget* parent = 0 );
|
||||||
|
~OperationGUI_TransferDataDlg();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// redefined from GEOMBase_Helper
|
||||||
|
virtual GEOM::GEOM_IOperations_ptr createOperation();
|
||||||
|
virtual bool isValid( QString& );
|
||||||
|
virtual bool execute( ObjectList& );
|
||||||
|
|
||||||
|
private:
|
||||||
|
void Init();
|
||||||
|
void enterEvent( QEvent* );
|
||||||
|
|
||||||
|
private:
|
||||||
|
GEOM::GeomObjPtr myObject1;
|
||||||
|
GEOM::GeomObjPtr myObject2;
|
||||||
|
int myShapeType;
|
||||||
|
|
||||||
|
DlgRef_2Sel1List* myGroup;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void ClickOnOk();
|
||||||
|
bool ClickOnApply();
|
||||||
|
void SetEditCurrentArgument();
|
||||||
|
void SelectionIntoArgument();
|
||||||
|
void LineEditReturnPressed();
|
||||||
|
void ActivateThisDialog();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // OPERATIONGUI_GETSHAPESONSHAPEDLG_H
|
Loading…
Reference in New Issue
Block a user