mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2024-12-27 09:50:34 +05:00
0022776: [CEA 1269] Project a wire or a face on a cylinder
This commit is contained in:
parent
e450289112
commit
0081236a16
BIN
doc/salome/gui/GEOM/images/proj_on_cyl_dlg.png
Normal file
BIN
doc/salome/gui/GEOM/images/proj_on_cyl_dlg.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 25 KiB |
BIN
doc/salome/gui/GEOM/images/proj_on_cyl_preview.png
Normal file
BIN
doc/salome/gui/GEOM/images/proj_on_cyl_preview.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.1 KiB |
@ -0,0 +1,41 @@
|
||||
/*!
|
||||
|
||||
\page projection_on_cylinder_operation_page Projection on Cylinder
|
||||
|
||||
\n To produce a <b>Projection on Cylinder</b> in the <b>Main Menu</b> select
|
||||
<b>Operations - > Transformation - > Projection on Cylinder</b>
|
||||
|
||||
\n This operation makes a projection of a <b>Source planar wire or face</b> on
|
||||
a cylinder defined by its radius. The cylinder's coordinate system is
|
||||
the same as the global coordinate system. The result represents a wire or
|
||||
a face or a compound of faces that represents a projection of the source
|
||||
shape onto a cylinder.
|
||||
|
||||
To make a projection it is necessary to define:
|
||||
- \b Object to be rotated. It can be either a planar wire or a face;
|
||||
- \b Radius of the cylinder;
|
||||
- <b>Starting angle</b> from the cylinder's X axis around Z axis. This is
|
||||
the angle of the projection starting.
|
||||
- <b>Length angle</b> in which to project the total length of
|
||||
the wire. If it is unchecked the projection is not scaled and natural
|
||||
wire length is kept for the projection.
|
||||
|
||||
\ref restore_presentation_parameters_page "Advanced options".
|
||||
|
||||
\image html proj_on_cyl_dlg.png
|
||||
|
||||
\n <b>Example:</b>
|
||||
|
||||
\image html proj_on_cyl_preview.png "The curve (in red) and its projection on the cylinder"
|
||||
|
||||
\n <b>TUI Command:</b> <em>geompy.MakeProjectionOnCylinder(theObject, theRadius,
|
||||
theStartAngle=0.0, theAngleLength=-1.0),</em>
|
||||
where \em theObject is a shape which has to be projected, \em theRadius
|
||||
is a cylinder radius, \em theStartAngle the starting angle of projection in
|
||||
radians, \em theAngleLength the projection length angle in radians.
|
||||
The \em Result will be a \em GEOM_Object.
|
||||
|
||||
Our <b>TUI Scripts</b> provide you with useful examples of the use of
|
||||
\ref tui_projection "Transformation Operations".
|
||||
|
||||
*/
|
@ -17,6 +17,7 @@ which allow to:
|
||||
<li>Create an \subpage offset_operation_page "Offset" of an object.</li>
|
||||
<li>Create a \subpage projection_operation_page "Projection" of an object on a face.</li>
|
||||
<li>Create an \subpage extension_operation_page "Extension" of an edge or a face.</li>
|
||||
<li>Create a \subpage projection_on_cylinder_operation_page "Projection on cylinder".</li>
|
||||
<li>Create a simultaneous \subpage multi_translation_operation_page "Translation in several directions".</li>
|
||||
<li>Create a simultaneous \subpage multi_rotation_operation_page</li> "Rotation in several directions".</li>
|
||||
</ul>
|
||||
|
@ -1420,6 +1420,31 @@ module GEOM
|
||||
* \return theObject.
|
||||
*/
|
||||
GEOM_Object RecomputeObject (in GEOM_Object theObject);
|
||||
|
||||
/*!
|
||||
* \brief Compute the projection of a wire or a face on a cylinder.
|
||||
*
|
||||
* This method computes a wire or a face or a compound of faces
|
||||
* that represents a projection of the source shape onto cylinder.
|
||||
* The cylinder's coordinate system is the same as the global coordinate
|
||||
* system.
|
||||
*
|
||||
* \param theObject The object to be projected. It can be either
|
||||
* a planar wire or a face.
|
||||
* \param theRadius The radius of the cylinder.
|
||||
* \param theStartAngle The starting angle from the cylinder's X axis
|
||||
* around Z axis. The angle from which the projection is started.
|
||||
* \param theAngleLength The projection length angle. The angle in which
|
||||
* to project the total length of the wire. If it is negative the
|
||||
* projection is not scaled and natural wire length is kept for
|
||||
* the projection.
|
||||
* \return A wire or a face or a compound of faces that represents a
|
||||
* projection of the source shape onto a cylinder.
|
||||
*/
|
||||
GEOM_Object MakeProjectionOnCylinder (in GEOM_Object theObject,
|
||||
in double theRadius,
|
||||
in double theStartAngle,
|
||||
in double theAngleLength);
|
||||
};
|
||||
|
||||
/*!
|
||||
|
@ -134,6 +134,7 @@ SET( _res_files
|
||||
projection.png
|
||||
projection_on_edge.png
|
||||
projection_on_wire.png
|
||||
proj_on_cyl.png
|
||||
origin_and_vectors.png
|
||||
partition.png
|
||||
partitionkeep.png
|
||||
|
BIN
resources/proj_on_cyl.png
Normal file
BIN
resources/proj_on_cyl.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 792 B |
@ -463,6 +463,10 @@
|
||||
<source>ICON_DLG_EXTEND_FACE</source>
|
||||
<translation>faceextension.png</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>ICO_DLG_PROJ_ON_CYL</source>
|
||||
<translation>proj_on_cyl.png</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>ICON_DLG_PARTITION</source>
|
||||
<translation>partition.png</translation>
|
||||
@ -1143,6 +1147,10 @@
|
||||
<source>ICO_EXTENSION</source>
|
||||
<translation>edgeextension.png</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>ICO_PROJ_ON_CYL</source>
|
||||
<translation>proj_on_cyl.png</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>ICO_ORIGIN_AND_VECTORS</source>
|
||||
<translation>origin_and_vectors.png</translation>
|
||||
|
@ -1248,6 +1248,10 @@ Please, select face, shell or solid and try again</translation>
|
||||
<source>GEOM_PROJECTION_TITLE</source>
|
||||
<translation>Projection</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>GEOM_PROJECTION_NAME</source>
|
||||
<translation>Projection</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>GEOM_PROJ_ON_FACE_SOURCE</source>
|
||||
<translation>Source vertex, edge or wire</translation>
|
||||
@ -2832,6 +2836,10 @@ Please, select face, shell or solid and try again</translation>
|
||||
<source>MEN_PROJECTION</source>
|
||||
<translation>Projection</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MEN_PROJ_ON_CYL</source>
|
||||
<translation>Projection on Cylinder</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MEN_OPERATIONS</source>
|
||||
<translation>Operations</translation>
|
||||
@ -3768,6 +3776,10 @@ Please, select face, shell or solid and try again</translation>
|
||||
<source>STB_PROJECTION</source>
|
||||
<translation>Project a point, an edge or a wire on a face</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>STB_PROJ_ON_CYL</source>
|
||||
<translation>Project a wire or a face on a cylinder</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>STB_ORIGIN_AND_VECTORS</source>
|
||||
<translation>Create an origin and base Vectors</translation>
|
||||
@ -4376,6 +4388,10 @@ Please, select face, shell or solid and try again</translation>
|
||||
<source>TOP_PROJECTION</source>
|
||||
<translation>Projection</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>TOP_PROJ_ON_CYL</source>
|
||||
<translation>Projection on Cylinder</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>TOP_ORIGIN_AND_VECTORS</source>
|
||||
<translation>Create an origin and base Vectors</translation>
|
||||
@ -7353,4 +7369,19 @@ Do you want to create new material?</translation>
|
||||
<translation>Materials: %1 of %2</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>TransformationGUI_ProjectionOnCylDlg</name>
|
||||
<message>
|
||||
<source>GEOM_PROJ_ON_CYL_TITLE</source>
|
||||
<translation>Projection On A Cylinder</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>GEOM_PROJ_ON_CYL_START_ANGLE</source>
|
||||
<translation>Starting angle</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>GEOM_PROJ_ON_CYL_LENGTH_ANGLE</source>
|
||||
<translation>Length angle</translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
@ -585,6 +585,7 @@ void GeometryGUI::OnGUIEvent( int id, const QVariant& theParam )
|
||||
case GEOMOp::OpScale: // MENU TRANSFORMATION - SCALE
|
||||
case GEOMOp::OpOffset: // MENU TRANSFORMATION - OFFSET
|
||||
case GEOMOp::OpProjection: // MENU TRANSFORMATION - PROJECTION
|
||||
case GEOMOp::OpProjOnCyl: // MENU TRANSFORMATION - PROJECTION ON CYLINDER
|
||||
case GEOMOp::OpMultiTranslate: // MENU TRANSFORMATION - MULTI-TRANSLATION
|
||||
case GEOMOp::OpMultiRotate: // MENU TRANSFORMATION - MULTI-ROTATION
|
||||
case GEOMOp::OpReimport: // CONTEXT(POPUP) MENU - RELOAD_IMPORTED
|
||||
@ -963,6 +964,7 @@ void GeometryGUI::initialize( CAM_Application* app )
|
||||
createGeomAction( GEOMOp::OpScale, "SCALE" );
|
||||
createGeomAction( GEOMOp::OpOffset, "OFFSET" );
|
||||
createGeomAction( GEOMOp::OpProjection, "PROJECTION" );
|
||||
createGeomAction( GEOMOp::OpProjOnCyl, "PROJ_ON_CYL" );
|
||||
createGeomAction( GEOMOp::OpMultiTranslate, "MUL_TRANSLATION" );
|
||||
createGeomAction( GEOMOp::OpMultiRotate, "MUL_ROTATION" );
|
||||
createGeomAction( GEOMOp::OpExtension, "EXTENSION" );
|
||||
@ -1205,6 +1207,7 @@ void GeometryGUI::initialize( CAM_Application* app )
|
||||
createMenu( GEOMOp::OpOffset, transId, -1 );
|
||||
createMenu( GEOMOp::OpProjection, transId, -1 );
|
||||
createMenu( GEOMOp::OpExtension, transId, -1 );
|
||||
createMenu( GEOMOp::OpProjOnCyl, transId, -1 );
|
||||
createMenu( separator(), transId, -1 );
|
||||
createMenu( GEOMOp::OpMultiTranslate, transId, -1 );
|
||||
createMenu( GEOMOp::OpMultiRotate, transId, -1 );
|
||||
@ -1378,6 +1381,7 @@ void GeometryGUI::initialize( CAM_Application* app )
|
||||
createTool( GEOMOp::OpOffset, transTbId );
|
||||
createTool( GEOMOp::OpProjection, transTbId );
|
||||
createTool( GEOMOp::OpExtension, transTbId );
|
||||
createTool( GEOMOp::OpProjOnCyl, transTbId );
|
||||
createTool( separator(), transTbId );
|
||||
createTool( GEOMOp::OpMultiTranslate, transTbId );
|
||||
createTool( GEOMOp::OpMultiRotate, transTbId );
|
||||
|
@ -145,6 +145,7 @@ namespace GEOMOp {
|
||||
OpReimport = 3608, // POPUP MENU - RELOAD IMPORTED
|
||||
OpProjection = 3609, // MENU OPERATIONS - TRANSFORMATION - PROJECTION
|
||||
OpExtension = 3610, // MENU OPERATIONS - TRANSFORMATION - EXTENSION
|
||||
OpProjOnCyl = 3611, // MENU OPERATIONS - TRANSFORMATION - PROJECTION ON CYLINDER
|
||||
// OperationGUI ----------------//--------------------------------
|
||||
OpPartition = 3700, // MENU OPERATION - PARTITION
|
||||
OpArchimede = 3701, // MENU OPERATION - ARCHIMEDE
|
||||
|
@ -98,6 +98,7 @@ SET(GEOMImpl_HEADERS
|
||||
GEOMImpl_ITranslate.hxx
|
||||
GEOMImpl_IMirror.hxx
|
||||
GEOMImpl_IProjection.hxx
|
||||
GEOMImpl_IProjOnCyl.hxx
|
||||
GEOMImpl_IOffset.hxx
|
||||
GEOMImpl_IScale.hxx
|
||||
GEOMImpl_IRotate.hxx
|
||||
|
61
src/GEOMImpl/GEOMImpl_IProjOnCyl.hxx
Normal file
61
src/GEOMImpl/GEOMImpl_IProjOnCyl.hxx
Normal file
@ -0,0 +1,61 @@
|
||||
// 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 interface to a function for the Projection on cylinder creation.
|
||||
|
||||
#include "GEOM_Function.hxx"
|
||||
|
||||
#define PROJECTION_ARG_SHAPE 1
|
||||
#define PROJECTION_ARG_RADIUS 2
|
||||
#define PROJECTION_ARG_START_ANGLE 3
|
||||
#define PROJECTION_ARG_ANGLE_LENGTH 4
|
||||
|
||||
class GEOMImpl_IProjOnCyl
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
GEOMImpl_IProjOnCyl(Handle(GEOM_Function) theFunction): _func(theFunction) {}
|
||||
|
||||
void SetShape (const Handle(GEOM_Function) &theShape)
|
||||
{ _func->SetReference(PROJECTION_ARG_SHAPE, theShape); }
|
||||
void SetRadius (const Standard_Real theRadius)
|
||||
{ _func->SetReal(PROJECTION_ARG_RADIUS, theRadius); }
|
||||
void SetStartAngle (const Standard_Real theStartAngle)
|
||||
{ _func->SetReal(PROJECTION_ARG_START_ANGLE, theStartAngle); }
|
||||
void SetAngleLength (const Standard_Real theAngleLength)
|
||||
{ _func->SetReal(PROJECTION_ARG_ANGLE_LENGTH, theAngleLength); }
|
||||
|
||||
Handle(GEOM_Function) GetShape()
|
||||
{ return _func->GetReference(PROJECTION_ARG_SHAPE); }
|
||||
Standard_Real GetRadius()
|
||||
{ return _func->GetReal(PROJECTION_ARG_RADIUS ); }
|
||||
Standard_Real GetStartAngle()
|
||||
{ return _func->GetReal(PROJECTION_ARG_START_ANGLE ); }
|
||||
Standard_Real GetAngleLength()
|
||||
{ return _func->GetReal(PROJECTION_ARG_ANGLE_LENGTH ); }
|
||||
|
||||
private:
|
||||
|
||||
Handle(GEOM_Function) _func;
|
||||
|
||||
};
|
@ -35,6 +35,7 @@
|
||||
#include <GEOMImpl_ITranslate.hxx>
|
||||
#include <GEOMImpl_IMirror.hxx>
|
||||
#include <GEOMImpl_IProjection.hxx>
|
||||
#include <GEOMImpl_IProjOnCyl.hxx>
|
||||
#include <GEOMImpl_IOffset.hxx>
|
||||
#include <GEOMImpl_IScale.hxx>
|
||||
#include <GEOMImpl_IRotate.hxx>
|
||||
@ -2267,3 +2268,78 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::TransformLikeOtherCopy
|
||||
SetErrorCode(OK);
|
||||
return aCopy;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* MakeProjectionOnCylinder
|
||||
*/
|
||||
//=============================================================================
|
||||
Handle(GEOM_Object) GEOMImpl_ITransformOperations::MakeProjectionOnCylinder
|
||||
(const Handle(GEOM_Object) &theObject,
|
||||
const Standard_Real theRadius,
|
||||
const Standard_Real theStartAngle,
|
||||
const Standard_Real theAngleLength)
|
||||
{
|
||||
SetErrorCode(KO);
|
||||
|
||||
if (theObject.IsNull()) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
|
||||
|
||||
if (aLastFunction.IsNull()) {
|
||||
//There is no function which creates an object to be projected
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//Add a new Projection object
|
||||
Handle(GEOM_Object) aResult =
|
||||
GetEngine()->AddObject(GetDocID(), GEOM_PROJECTION);
|
||||
|
||||
//Add a Projection function
|
||||
Handle(GEOM_Function) aFunction = aResult->AddFunction
|
||||
(GEOMImpl_ProjectionDriver::GetID(), PROJECTION_ON_CYLINDER);
|
||||
|
||||
//Check if the function is set correctly
|
||||
if (aFunction->GetDriverGUID() != GEOMImpl_ProjectionDriver::GetID()) {
|
||||
return aResult;
|
||||
}
|
||||
|
||||
GEOMImpl_IProjOnCyl aProj (aFunction);
|
||||
|
||||
aProj.SetShape(aLastFunction);
|
||||
aProj.SetRadius(theRadius);
|
||||
aProj.SetStartAngle(theStartAngle);
|
||||
aProj.SetAngleLength(theAngleLength);
|
||||
|
||||
//Compute the Projection
|
||||
try {
|
||||
OCC_CATCH_SIGNALS;
|
||||
if (!GetSolver()->ComputeFunction(aFunction)) {
|
||||
SetErrorCode("Projection driver failed");
|
||||
return aResult;
|
||||
}
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle(Standard_Failure) aFail = Standard_Failure::Caught();
|
||||
SetErrorCode(aFail->GetMessageString());
|
||||
return aResult;
|
||||
}
|
||||
|
||||
//Make a Python command
|
||||
GEOM::TPythonDump pd(aFunction);
|
||||
|
||||
pd << aResult << " = geompy.MakeProjectionOnCylinder("
|
||||
<< theObject << ", " << theRadius << ", " << theStartAngle;
|
||||
|
||||
if (theAngleLength >= 0.) {
|
||||
pd << ", " << theAngleLength;
|
||||
}
|
||||
|
||||
pd << ")";
|
||||
|
||||
SetErrorCode(OK);
|
||||
|
||||
return aResult;
|
||||
}
|
||||
|
@ -191,6 +191,12 @@ class GEOMImpl_ITransformOperations : public GEOM_IOperations
|
||||
Standard_EXPORT Handle(GEOM_Object) TransformLikeOtherCopy (Handle(GEOM_Object) theObject,
|
||||
Handle(GEOM_Object) theSample);
|
||||
|
||||
Standard_EXPORT Handle(GEOM_Object) MakeProjectionOnCylinder
|
||||
(const Handle(GEOM_Object) &theObject,
|
||||
const Standard_Real theRadius,
|
||||
const Standard_Real theStartAngle,
|
||||
const Standard_Real theAngleLength);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -26,16 +26,26 @@
|
||||
|
||||
#include <GEOMImpl_IMirror.hxx>
|
||||
#include <GEOMImpl_IProjection.hxx>
|
||||
#include <GEOMImpl_IProjOnCyl.hxx>
|
||||
#include <GEOMImpl_Types.hxx>
|
||||
#include <GEOM_Function.hxx>
|
||||
#include <GEOMUtils.hxx>
|
||||
#include <GEOMUtils_HTrsfCurve2d.hxx>
|
||||
|
||||
#include <Approx_Curve2d.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <BRepAdaptor_Curve2d.hxx>
|
||||
#include <BRepBuilderAPI_Transform.hxx>
|
||||
#include <BRepBuilderAPI_MakeEdge.hxx>
|
||||
#include <BRepBuilderAPI_MakeFace.hxx>
|
||||
#include <BRepBuilderAPI_MakeVertex.hxx>
|
||||
#include <BRepBuilderAPI_MakeWire.hxx>
|
||||
#include <BRepClass_FaceClassifier.hxx>
|
||||
#include <BRepExtrema_DistShapeShape.hxx>
|
||||
#include <BRepLib.hxx>
|
||||
#include <BRepOffsetAPI_NormalProjection.hxx>
|
||||
#include <BRepTools.hxx>
|
||||
#include <BRepTools_WireExplorer.hxx>
|
||||
|
||||
#include <TopAbs.hxx>
|
||||
#include <TopExp.hxx>
|
||||
@ -44,11 +54,14 @@
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <TopoDS_Face.hxx>
|
||||
#include <TopoDS_Vertex.hxx>
|
||||
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
|
||||
#include <TopoDS_Wire.hxx>
|
||||
#include <TopTools_ListIteratorOfListOfShape.hxx>
|
||||
|
||||
#include <GeomAPI_ProjectPointOnSurf.hxx>
|
||||
#include <Geom_Curve.hxx>
|
||||
#include <Geom_CylindricalSurface.hxx>
|
||||
#include <Geom_Plane.hxx>
|
||||
#include <Geom2d_TrimmedCurve.hxx>
|
||||
|
||||
#include <gp_Trsf.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
@ -400,6 +413,42 @@ Standard_Integer GEOMImpl_ProjectionDriver::Execute(TFunction_Logbook& log) cons
|
||||
if (!hasValidSolution) {
|
||||
Standard_ConstructionError::Raise("Projection aborted : no projection");
|
||||
}
|
||||
} else if (aType == PROJECTION_ON_CYLINDER) {
|
||||
GEOMImpl_IProjOnCyl aProj (aFunction);
|
||||
Handle(GEOM_Function) aShapeFunction = aProj.GetShape();
|
||||
|
||||
if (aShapeFunction.IsNull()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
TopoDS_Shape aShape = aShapeFunction->GetValue();
|
||||
|
||||
if (aShape.IsNull()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Get the face.
|
||||
const TopAbs_ShapeEnum aType = aShape.ShapeType();
|
||||
const Standard_Real aRadius = aProj.GetRadius();
|
||||
const Standard_Real aStartAngle = aProj.GetStartAngle();
|
||||
const Standard_Real aLengthAngle = aProj.GetAngleLength();
|
||||
|
||||
if (aType != TopAbs_WIRE && aType != TopAbs_FACE) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (aRadius <= Precision::Confusion()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
TopoDS_Shape aProjShape =
|
||||
projectOnCylinder(aShape, aRadius, aStartAngle, aLengthAngle);
|
||||
|
||||
if (aProjShape.IsNull()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
aFunction->SetValue(aProjShape);
|
||||
}
|
||||
|
||||
return 1;
|
||||
@ -438,6 +487,21 @@ GetCreationInformation(std::string& theOperationName,
|
||||
AddParam(theParams, "Point", aProj.GetPoint());
|
||||
AddParam(theParams, "Shape", aProj.GetShape());
|
||||
|
||||
break;
|
||||
}
|
||||
case PROJECTION_ON_CYLINDER:
|
||||
{
|
||||
GEOMImpl_IProjOnCyl aProj (function);
|
||||
const Standard_Real aLengthAngle = aProj.GetAngleLength();
|
||||
|
||||
AddParam(theParams, "Shape", aProj.GetShape());
|
||||
AddParam(theParams, "Radius", aProj.GetRadius());
|
||||
AddParam(theParams, "Start angle", aProj.GetStartAngle());
|
||||
|
||||
if (aLengthAngle >= 0.) {
|
||||
AddParam(theParams, "Length angle", aLengthAngle);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@ -447,5 +511,242 @@ GetCreationInformation(std::string& theOperationName,
|
||||
return true;
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Performs projection of a planar wire or a face on a cylinder.
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
TopoDS_Shape GEOMImpl_ProjectionDriver::projectOnCylinder
|
||||
(const TopoDS_Shape &theShape,
|
||||
const Standard_Real theRadius,
|
||||
const Standard_Real theStartAngle,
|
||||
const Standard_Real theAngleLength) const
|
||||
{
|
||||
TopoDS_Shape aResult;
|
||||
|
||||
// Get the face.
|
||||
const TopAbs_ShapeEnum aType = theShape.ShapeType();
|
||||
TopoDS_Face aFace;
|
||||
|
||||
if (aType == TopAbs_WIRE) {
|
||||
// Try to create a planar face.
|
||||
TopoDS_Wire aWire = TopoDS::Wire(theShape);
|
||||
BRepBuilderAPI_MakeFace aMkFace(aWire, Standard_True);
|
||||
|
||||
if (aMkFace.IsDone()) {
|
||||
aFace = aMkFace.Face();
|
||||
} else {
|
||||
// Check if the wire is a straight line.
|
||||
TopExp_Explorer anEExp(aWire, TopAbs_EDGE);
|
||||
TopoDS_Edge anEdge;
|
||||
|
||||
for (; anEExp.More(); anEExp.Next()) {
|
||||
anEdge = TopoDS::Edge(anEExp.Current());
|
||||
|
||||
if (!BRep_Tool::Degenerated(anEdge)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (anEExp.More()) {
|
||||
// Not degenerated edge found. Try to create a plane.
|
||||
Standard_Real aPar[2];
|
||||
Handle(Geom_Curve) aCurve = BRep_Tool::Curve(anEdge, aPar[0], aPar[1]);
|
||||
gp_Pnt aP0 = aCurve->Value(aPar[0]);
|
||||
gp_Pnt aP1 = aCurve->Value(0.5*(aPar[1] + aPar[0]));
|
||||
gp_Vec aX(aP1.XYZ().Subtracted(aP0.XYZ()));
|
||||
Standard_Real aTolConf = Precision::Confusion();
|
||||
|
||||
if (aX.Magnitude() > aTolConf) {
|
||||
aX.Normalize();
|
||||
|
||||
// Get the plane normal ortogonal to Z axis.
|
||||
gp_Vec aZ(0., 0., 1.);
|
||||
gp_Vec aN = aX.Crossed(aZ);
|
||||
|
||||
if (aN.Magnitude() <= aTolConf) {
|
||||
// aX is parallel to aZ. Get the plane normal ortogonal to Y axis.
|
||||
gp_Vec aY(0., 1., 0.);
|
||||
|
||||
aN = aX.Crossed(aY);
|
||||
}
|
||||
|
||||
if (aN.Magnitude() > aTolConf) {
|
||||
gp_Ax3 anAxis(aP0, gp_Dir(aN), gp_Dir(aX));
|
||||
Handle(Geom_Plane) aPlane = new Geom_Plane(anAxis);
|
||||
BRepBuilderAPI_MakeFace aMkFace(aPlane, aWire);
|
||||
|
||||
if (aMkFace.IsDone()) {
|
||||
aFace = aMkFace.Face();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (aType == TopAbs_FACE) {
|
||||
aFace = TopoDS::Face(theShape);
|
||||
}
|
||||
|
||||
if (aFace.IsNull()) {
|
||||
return aResult;
|
||||
}
|
||||
|
||||
// Compute 2d translation transformation.
|
||||
TopoDS_Wire anOuterWire = BRepTools::OuterWire(aFace);
|
||||
Standard_Real aU[2];
|
||||
Standard_Real aV[2];
|
||||
BRepTools_WireExplorer aOWExp(anOuterWire, aFace);
|
||||
|
||||
if (!aOWExp.More()) {
|
||||
// NEVERREACHED
|
||||
return aResult;
|
||||
}
|
||||
|
||||
// Compute anisotropic transformation from a face's 2d space
|
||||
// to cylinder's 2d space.
|
||||
BRepTools::UVBounds(aFace, anOuterWire, aU[0], aU[1], aV[0], aV[1]);
|
||||
|
||||
TopoDS_Vertex aFirstVertex = aOWExp.CurrentVertex();
|
||||
TopoDS_Edge aFirstEdge = aOWExp.Current();
|
||||
gp_Pnt aPnt = BRep_Tool::Pnt(aFirstVertex);
|
||||
BRepAdaptor_Curve2d anAdaptorCurve(aFirstEdge, aFace);
|
||||
Standard_Real aParam =
|
||||
BRep_Tool::Parameter(aFirstVertex, aFirstEdge, aFace);
|
||||
gp_Pnt2d aPntUV = anAdaptorCurve.Value(aParam);
|
||||
|
||||
GEOMUtils::Trsf2d aTrsf2d
|
||||
(1./theRadius, 0., theStartAngle - aU[0]/theRadius,
|
||||
0., 1., aPnt.Z() - 0.5*(aV[1] - aV[0]) - aPntUV.Y());
|
||||
|
||||
// Compute scaling trsf.
|
||||
const Standard_Boolean isToScale = theAngleLength >= Precision::Angular();
|
||||
gp_Trsf2d aScaleTrsf;
|
||||
|
||||
if (isToScale) {
|
||||
// Perform 2d scaling.
|
||||
gp_Pnt2d aMidPnt(0.5*(aU[1] + aU[0]), 0.5*(aV[1] + aV[0]));
|
||||
const Standard_Real aScaleFactor = theAngleLength*theRadius/(aU[1] - aU[0]);
|
||||
|
||||
aTrsf2d.TransformD0(aMidPnt);
|
||||
|
||||
aScaleTrsf.SetScale(aMidPnt, aScaleFactor);
|
||||
}
|
||||
|
||||
// Get 2d presentation of a face.
|
||||
Handle(Geom_Surface) aCylinder =
|
||||
new Geom_CylindricalSurface(gp_Ax3(), theRadius);
|
||||
GeomAdaptor_Surface aGACyl(aCylinder);
|
||||
TopExp_Explorer anExp(aFace, TopAbs_WIRE);
|
||||
Standard_Real aPar[2];
|
||||
TopTools_ListOfShape aWires;
|
||||
Standard_Real aUResol = aGACyl.UResolution(Precision::Confusion());
|
||||
Standard_Real aVResol = aGACyl.VResolution(Precision::Confusion());
|
||||
|
||||
for (; anExp.More(); anExp.Next()) {
|
||||
TopoDS_Wire aWire = TopoDS::Wire(anExp.Current());
|
||||
BRepTools_WireExplorer aWExp(aWire, aFace);
|
||||
BRepBuilderAPI_MakeWire aMkWire;
|
||||
|
||||
for (; aWExp.More(); aWExp.Next()) {
|
||||
TopoDS_Edge anEdge = aWExp.Current();
|
||||
Handle(Geom2d_Curve) aCurve =
|
||||
BRep_Tool::CurveOnSurface(anEdge, aFace, aPar[0], aPar[1]);
|
||||
|
||||
if (aCurve.IsNull()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Transform the curve to cylinder's parametric space.
|
||||
GEOMUtils::Handle(HTrsfCurve2d) aTrsfCurve =
|
||||
new GEOMUtils::HTrsfCurve2d(aCurve, aPar[0], aPar[1], aTrsf2d);
|
||||
Approx_Curve2d aConv (aTrsfCurve, aPar[0], aPar[1],
|
||||
aUResol, aVResol, GeomAbs_C1,
|
||||
9, 1000);
|
||||
|
||||
if (!aConv.IsDone() && !aConv.HasResult()) {
|
||||
return aResult;
|
||||
}
|
||||
|
||||
Handle(Geom2d_Curve) aCylCurve = aConv.Curve();
|
||||
|
||||
if (isToScale) {
|
||||
aCylCurve->Transform(aScaleTrsf);
|
||||
}
|
||||
|
||||
// Create edge and add it to the wire.
|
||||
BRepBuilderAPI_MakeEdge aMkEdge(aCylCurve, aCylinder);
|
||||
|
||||
if (!aMkEdge.IsDone()) {
|
||||
return aResult;
|
||||
}
|
||||
|
||||
aMkWire.Add(aMkEdge.Edge());
|
||||
|
||||
if (!aMkWire.IsDone()) {
|
||||
return aResult;
|
||||
}
|
||||
}
|
||||
|
||||
if (aWire.IsSame(anOuterWire)) {
|
||||
// Make the outer wire first.
|
||||
aWires.Prepend(aMkWire.Wire());
|
||||
} else {
|
||||
aWires.Append(aMkWire.Wire());
|
||||
}
|
||||
}
|
||||
|
||||
// Create a face.
|
||||
if (aWires.IsEmpty()) {
|
||||
return aResult;
|
||||
}
|
||||
|
||||
TopTools_ListIteratorOfListOfShape aWIter(aWires);
|
||||
TopoDS_Wire aWire = TopoDS::Wire(aWIter.Value());
|
||||
BRepBuilderAPI_MakeFace aMkFace(aCylinder, aWire);
|
||||
|
||||
if (!aMkFace.IsDone()) {
|
||||
return aResult;
|
||||
}
|
||||
|
||||
for (aWIter.Next(); aWIter.More(); aWIter.Next()) {
|
||||
aWire = TopoDS::Wire(aWIter.Value());
|
||||
aMkFace.Add(aWire);
|
||||
|
||||
if (!aMkFace.IsDone()) {
|
||||
return aResult;
|
||||
}
|
||||
}
|
||||
|
||||
// Build 3D curves.
|
||||
TopoDS_Face aCylFace = aMkFace.Face();
|
||||
TopoDS_Shape aResShape;
|
||||
|
||||
BRepLib::BuildCurves3d(aCylFace);
|
||||
|
||||
// Check shape.
|
||||
if (aType == TopAbs_WIRE) {
|
||||
TopExp_Explorer aResExp(aCylFace, TopAbs_WIRE);
|
||||
|
||||
if (aResExp.More()) {
|
||||
aResShape = aResExp.Current();
|
||||
}
|
||||
} else {
|
||||
aResShape = aCylFace;
|
||||
}
|
||||
|
||||
if (aResShape.IsNull() == Standard_False) {
|
||||
if (!GEOMUtils::CheckShape(aResShape, true)) {
|
||||
if (!GEOMUtils::FixShapeTolerance(aResShape)) {
|
||||
return aResult;
|
||||
}
|
||||
}
|
||||
|
||||
aResult = aResShape;
|
||||
}
|
||||
|
||||
return aResult;
|
||||
}
|
||||
|
||||
IMPLEMENT_STANDARD_HANDLE (GEOMImpl_ProjectionDriver,GEOM_BaseDriver);
|
||||
IMPLEMENT_STANDARD_RTTIEXT (GEOMImpl_ProjectionDriver,GEOM_BaseDriver);
|
||||
|
@ -58,6 +58,7 @@
|
||||
#endif
|
||||
|
||||
class TColStd_SequenceOfExtendedString;
|
||||
class TopoDS_Shape;
|
||||
|
||||
|
||||
#include "GEOM_BaseDriver.hxx"
|
||||
@ -81,6 +82,15 @@ Standard_EXPORT ~GEOMImpl_ProjectionDriver() {};
|
||||
bool GetCreationInformation(std::string& theOperationName,
|
||||
std::vector<GEOM_Param>& params);
|
||||
|
||||
private:
|
||||
|
||||
TopoDS_Shape projectOnCylinder(const TopoDS_Shape &theShape,
|
||||
const Standard_Real theRadius,
|
||||
const Standard_Real theStartAngle,
|
||||
const Standard_Real theAngleLength) const;
|
||||
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_RTTI( GEOMImpl_ProjectionDriver )
|
||||
};
|
||||
|
||||
|
@ -185,8 +185,9 @@
|
||||
#define OFFSET_THICKENING 3
|
||||
#define OFFSET_THICKENING_COPY 4
|
||||
|
||||
#define PROJECTION_COPY 1
|
||||
#define PROJECTION_ON_WIRE 2
|
||||
#define PROJECTION_COPY 1
|
||||
#define PROJECTION_ON_WIRE 2
|
||||
#define PROJECTION_ON_CYLINDER 3
|
||||
|
||||
#define SCALE_SHAPE 1
|
||||
#define SCALE_SHAPE_COPY 2
|
||||
|
@ -52,6 +52,9 @@ SET(_link_LIBRARIES
|
||||
SET(GEOMUtils_HEADERS
|
||||
GEOMUtils.hxx
|
||||
GEOMUtils_Hatcher.hxx
|
||||
GEOMUtils_HTrsfCurve2d.hxx
|
||||
GEOMUtils_Trsf2d.hxx
|
||||
GEOMUtils_TrsfCurve2d.hxx
|
||||
GEOMUtils_XmlHandler.hxx
|
||||
)
|
||||
# --- sources ---
|
||||
@ -59,6 +62,9 @@ SET(GEOMUtils_HEADERS
|
||||
SET(GEOMUtils_SOURCES
|
||||
GEOMUtils.cxx
|
||||
GEOMUtils_Hatcher.cxx
|
||||
GEOMUtils_HTrsfCurve2d.cxx
|
||||
GEOMUtils_Trsf2d.cxx
|
||||
GEOMUtils_TrsfCurve2d.cxx
|
||||
GEOMUtils_XmlHandler.cxx
|
||||
)
|
||||
|
||||
|
51
src/GEOMUtils/GEOMUtils_HTrsfCurve2d.cxx
Normal file
51
src/GEOMUtils/GEOMUtils_HTrsfCurve2d.cxx
Normal file
@ -0,0 +1,51 @@
|
||||
// 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
|
||||
//
|
||||
|
||||
|
||||
#include <GEOMUtils_HTrsfCurve2d.hxx>
|
||||
|
||||
namespace GEOMUtils {
|
||||
IMPLEMENT_STANDARD_HANDLE (HTrsfCurve2d, Adaptor2d_HCurve2d);
|
||||
IMPLEMENT_STANDARD_RTTIEXT(HTrsfCurve2d, Adaptor2d_HCurve2d);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : TrsfCurve2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
GEOMUtils::HTrsfCurve2d::HTrsfCurve2d(const Handle(Geom2d_Curve) &theCurve,
|
||||
const Trsf2d &theTrsf)
|
||||
: myCurve (theCurve, theTrsf)
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : TrsfCurve2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
GEOMUtils::HTrsfCurve2d::HTrsfCurve2d(const Handle(Geom2d_Curve) &theCurve,
|
||||
const Standard_Real theUFirst,
|
||||
const Standard_Real theULast,
|
||||
const Trsf2d &theTrsf)
|
||||
: myCurve (theCurve, theUFirst, theULast, theTrsf)
|
||||
{
|
||||
}
|
84
src/GEOMUtils/GEOMUtils_HTrsfCurve2d.hxx
Normal file
84
src/GEOMUtils/GEOMUtils_HTrsfCurve2d.hxx
Normal file
@ -0,0 +1,84 @@
|
||||
// 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
|
||||
//
|
||||
|
||||
#ifndef _GEOMUtils_HTrsfCurve2d_HXX_
|
||||
#define _GEOMUtils_HTrsfCurve2d_HXX_
|
||||
|
||||
|
||||
#include <GEOMUtils_TrsfCurve2d.hxx>
|
||||
|
||||
#include <Adaptor2d_HCurve2d.hxx>
|
||||
|
||||
|
||||
namespace GEOMUtils
|
||||
{
|
||||
|
||||
class HTrsfCurve2d;
|
||||
|
||||
DEFINE_STANDARD_HANDLE(HTrsfCurve2d, Adaptor2d_HCurve2d);
|
||||
|
||||
/*!
|
||||
* This class represents an adaptor curve that represents an original curve
|
||||
* transformed by an anisotropic transformation. This is a class manipulated
|
||||
* by handle.
|
||||
*/
|
||||
class HTrsfCurve2d : public Adaptor2d_HCurve2d
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor. Initializes the object with the transformation parameters.
|
||||
* Input parameters are not checked for validity. It is under responsibility
|
||||
* of the caller.
|
||||
*/
|
||||
Standard_EXPORT HTrsfCurve2d(const Handle(Geom2d_Curve) &theCurve,
|
||||
const Trsf2d &theTrsf);
|
||||
|
||||
/**
|
||||
* Constructor. Initializes the object with the curve, first and last
|
||||
* parameters and transformation. Input parameters are not checked
|
||||
* for validity. It is under responsibility of the caller.
|
||||
*/
|
||||
Standard_EXPORT HTrsfCurve2d(const Handle(Geom2d_Curve) &theCurve,
|
||||
const Standard_Real theUFirst,
|
||||
const Standard_Real theULast,
|
||||
const Trsf2d &theTrsf);
|
||||
|
||||
/**
|
||||
* Redefined method from the base class.
|
||||
*/
|
||||
const Adaptor2d_Curve2d &Curve2d() const
|
||||
{ return myCurve; }
|
||||
|
||||
private:
|
||||
|
||||
TrsfCurve2d myCurve;
|
||||
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_RTTI(HTrsfCurve2d);
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
110
src/GEOMUtils/GEOMUtils_Trsf2d.cxx
Normal file
110
src/GEOMUtils/GEOMUtils_Trsf2d.cxx
Normal file
@ -0,0 +1,110 @@
|
||||
// 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
|
||||
//
|
||||
|
||||
|
||||
#include <GEOMUtils_Trsf2d.hxx>
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Trsf2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
GEOMUtils::Trsf2d::Trsf2d(const Standard_Real a11,
|
||||
const Standard_Real a12,
|
||||
const Standard_Real a13,
|
||||
const Standard_Real a21,
|
||||
const Standard_Real a22,
|
||||
const Standard_Real a23)
|
||||
: myA11(a11),
|
||||
myA12(a12),
|
||||
myA13(a13),
|
||||
myA21(a21),
|
||||
myA22(a22),
|
||||
myA23(a23)
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : TransformD0
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void GEOMUtils::Trsf2d::TransformD0(gp_Pnt2d &thePnt) const
|
||||
{
|
||||
const Standard_Real aX = myA11*thePnt.X() + myA12*thePnt.Y() + myA13;
|
||||
const Standard_Real aY = myA21*thePnt.X() + myA22*thePnt.Y() + myA23;
|
||||
|
||||
thePnt.SetCoord(aX, aY);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : TransformD1
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void GEOMUtils::Trsf2d::TransformD1(gp_Pnt2d &thePnt,
|
||||
gp_Vec2d &theVec1) const
|
||||
{
|
||||
TransformVector(thePnt, theVec1);
|
||||
TransformD0(thePnt);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : TransformD2
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void GEOMUtils::Trsf2d::TransformD2(gp_Pnt2d &thePnt,
|
||||
gp_Vec2d &theVec1,
|
||||
gp_Vec2d &theVec2) const
|
||||
{
|
||||
TransformVector(thePnt, theVec1);
|
||||
TransformVector(thePnt, theVec2);
|
||||
TransformD0(thePnt);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : TransformD3
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void GEOMUtils::Trsf2d::TransformD3(gp_Pnt2d &thePnt,
|
||||
gp_Vec2d &theVec1,
|
||||
gp_Vec2d &theVec2,
|
||||
gp_Vec2d &theVec3) const
|
||||
{
|
||||
TransformVector(thePnt, theVec1);
|
||||
TransformVector(thePnt, theVec2);
|
||||
TransformVector(thePnt, theVec3);
|
||||
TransformD0(thePnt);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : TransformVector
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void GEOMUtils::Trsf2d::TransformVector(const gp_Pnt2d &thePnt,
|
||||
gp_Vec2d &theVec) const
|
||||
{
|
||||
gp_Pnt2d aP0(thePnt.XY());
|
||||
gp_Pnt2d aP1(thePnt.XY().Added(theVec.XY()));
|
||||
|
||||
TransformD0(aP0);
|
||||
TransformD0(aP1);
|
||||
theVec.SetXY(aP1.XY().Subtracted(aP0.XY()));
|
||||
}
|
134
src/GEOMUtils/GEOMUtils_Trsf2d.hxx
Normal file
134
src/GEOMUtils/GEOMUtils_Trsf2d.hxx
Normal file
@ -0,0 +1,134 @@
|
||||
// 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
|
||||
//
|
||||
|
||||
#ifndef _GEOMUtils_Trsf2d_HXX_
|
||||
#define _GEOMUtils_Trsf2d_HXX_
|
||||
|
||||
|
||||
#include <Geom2dHatch_Hatcher.hxx>
|
||||
#include <GeomAbs_IsoType.hxx>
|
||||
#include <TColStd_HArray1OfInteger.hxx>
|
||||
#include <TColStd_HArray1OfReal.hxx>
|
||||
#include <TopoDS_Face.hxx>
|
||||
|
||||
|
||||
/*!
|
||||
* This class represents a non-persistent transformation in 2D space.
|
||||
* The transformations can be represented as follow :
|
||||
*
|
||||
* V1 V2 T XY XY
|
||||
* | a11 a12 a13 | | x | | x'|
|
||||
* | a21 a22 a23 | | y | | y'|
|
||||
* | 0 0 1 | | 1 | | 1 |
|
||||
|
||||
* where {V1, V2} defines the vectorial part of the transformation
|
||||
* and T defines the translation part of the transformation.
|
||||
* This transformation can change the nature of the objects if it is
|
||||
* anisotropic.
|
||||
*/
|
||||
namespace GEOMUtils
|
||||
{
|
||||
class Trsf2d
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor. Initializes the object with the transformation parameters.
|
||||
* Input parameters are not checked for validity. It is under responsibility
|
||||
* of the caller.
|
||||
*/
|
||||
Standard_EXPORT Trsf2d(const Standard_Real a11,
|
||||
const Standard_Real a12,
|
||||
const Standard_Real a13,
|
||||
const Standard_Real a21,
|
||||
const Standard_Real a22,
|
||||
const Standard_Real a23);
|
||||
|
||||
/**
|
||||
* Transform the point. The passed parameter is modified to have
|
||||
* a transformed value.
|
||||
*
|
||||
* \param thePnt the point.
|
||||
*/
|
||||
Standard_EXPORT void TransformD0(gp_Pnt2d &thePnt)const;
|
||||
|
||||
/**
|
||||
* Transform the point and the first derivative vector. The passed
|
||||
* parameters are modified to have a transformed value.
|
||||
*
|
||||
* \param thePnt the point.
|
||||
* \param theVec1 the first derivative vector.
|
||||
*/
|
||||
Standard_EXPORT void TransformD1(gp_Pnt2d &thePnt,
|
||||
gp_Vec2d &theVec1) const;
|
||||
|
||||
/**
|
||||
* Transform the point, the first and second derivative vectors. The passed
|
||||
* parameters are modified to have a transformed value.
|
||||
*
|
||||
* \param thePnt the point.
|
||||
* \param theVec1 the first derivative vector.
|
||||
* \param theVec2 the second derivative vector.
|
||||
*/
|
||||
Standard_EXPORT void TransformD2(gp_Pnt2d &thePnt,
|
||||
gp_Vec2d &theVec1,
|
||||
gp_Vec2d &theVec2) const;
|
||||
|
||||
/**
|
||||
* Transform the point, the first, second and third derivative vectors.
|
||||
* The passed parameters are modified to have a transformed value.
|
||||
*
|
||||
* \param thePnt the point.
|
||||
* \param theVec1 the first derivative vector.
|
||||
* \param theVec2 the second derivative vector.
|
||||
* \param theVec2 the third derivative vector.
|
||||
*/
|
||||
Standard_EXPORT void TransformD3(gp_Pnt2d &thePnt,
|
||||
gp_Vec2d &theVec1,
|
||||
gp_Vec2d &theVec2,
|
||||
gp_Vec2d &theVec3) const;
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* Transform the vector.
|
||||
*
|
||||
* \param thePnt the point.
|
||||
* \param theVec the vector.
|
||||
*/
|
||||
void TransformVector(const gp_Pnt2d &thePnt,
|
||||
gp_Vec2d &theVec) const;
|
||||
|
||||
private:
|
||||
|
||||
Standard_Real myA11;
|
||||
Standard_Real myA12;
|
||||
Standard_Real myA13;
|
||||
Standard_Real myA21;
|
||||
Standard_Real myA22;
|
||||
Standard_Real myA23;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
382
src/GEOMUtils/GEOMUtils_TrsfCurve2d.cxx
Normal file
382
src/GEOMUtils/GEOMUtils_TrsfCurve2d.cxx
Normal file
@ -0,0 +1,382 @@
|
||||
// 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
|
||||
//
|
||||
|
||||
|
||||
#include <GEOMUtils_TrsfCurve2d.hxx>
|
||||
#include <GEOMUtils_HTrsfCurve2d.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : TrsfCurve2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
GEOMUtils::TrsfCurve2d::TrsfCurve2d(const Handle(Geom2d_Curve) &theCurve,
|
||||
const Trsf2d &theTrsf)
|
||||
: myCurve (theCurve),
|
||||
myTrsf (theTrsf)
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : TrsfCurve2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
GEOMUtils::TrsfCurve2d::TrsfCurve2d(const Handle(Geom2d_Curve) &theCurve,
|
||||
const Standard_Real theUFirst,
|
||||
const Standard_Real theULast,
|
||||
const Trsf2d &theTrsf)
|
||||
: myCurve (theCurve, theUFirst, theULast),
|
||||
myTrsf (theTrsf)
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : FirstParameter
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Real GEOMUtils::TrsfCurve2d::FirstParameter() const
|
||||
{
|
||||
return myCurve.FirstParameter();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : LastParameter
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Real GEOMUtils::TrsfCurve2d::LastParameter() const
|
||||
{
|
||||
return myCurve.LastParameter();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Curve
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
const Handle(Geom2d_Curve) &GEOMUtils::TrsfCurve2d::Curve() const
|
||||
{
|
||||
return myCurve.Curve();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetType
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
GeomAbs_CurveType GEOMUtils::TrsfCurve2d::GetType() const
|
||||
{
|
||||
return GeomAbs_OtherCurve;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Load
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void GEOMUtils::TrsfCurve2d::Load(const Handle(Geom2d_Curve) &C)
|
||||
{
|
||||
myCurve.Load(C);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Load
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void GEOMUtils::TrsfCurve2d::Load(const Handle(Geom2d_Curve) &C,
|
||||
const Standard_Real UFirst,
|
||||
const Standard_Real ULast)
|
||||
{
|
||||
myCurve.Load(C, UFirst, ULast);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Continuity
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
GeomAbs_Shape GEOMUtils::TrsfCurve2d::Continuity() const
|
||||
{
|
||||
return myCurve.Continuity();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NbIntervals
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Integer GEOMUtils::TrsfCurve2d::NbIntervals
|
||||
(const GeomAbs_Shape S) const
|
||||
{
|
||||
return myCurve.NbIntervals(S);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Intervals
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void GEOMUtils::TrsfCurve2d::Intervals(TColStd_Array1OfReal &T,
|
||||
const GeomAbs_Shape S) const
|
||||
{
|
||||
myCurve.Intervals(T, S);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Trim
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(Adaptor2d_HCurve2d) GEOMUtils::TrsfCurve2d::Trim
|
||||
(const Standard_Real First, const Standard_Real Last,
|
||||
const Standard_Real /*Tol*/) const
|
||||
{
|
||||
Handle(Geom2d_Curve) aCurve = myCurve.Curve();
|
||||
GEOMUtils::Handle(HTrsfCurve2d) aAHCurve =
|
||||
new GEOMUtils::HTrsfCurve2d(aCurve, First, Last, myTrsf);
|
||||
|
||||
return aAHCurve;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsClosed
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean GEOMUtils::TrsfCurve2d::IsClosed() const
|
||||
{
|
||||
return myCurve.IsClosed();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsPeriodic
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean GEOMUtils::TrsfCurve2d::IsPeriodic() const
|
||||
{
|
||||
return myCurve.IsPeriodic();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Period
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Real GEOMUtils::TrsfCurve2d::Period() const
|
||||
{
|
||||
return myCurve.Period();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Value
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
gp_Pnt2d GEOMUtils::TrsfCurve2d::Value(const Standard_Real U) const
|
||||
{
|
||||
gp_Pnt2d aPnt = myCurve.Value(U);
|
||||
|
||||
myTrsf.TransformD0(aPnt);
|
||||
|
||||
return aPnt;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : D0
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void GEOMUtils::TrsfCurve2d::D0(const Standard_Real U, gp_Pnt2d &P) const
|
||||
{
|
||||
myCurve.D0(U, P);
|
||||
myTrsf.TransformD0(P);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : D1
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void GEOMUtils::TrsfCurve2d::D1(const Standard_Real U,
|
||||
gp_Pnt2d &P, gp_Vec2d &V) const
|
||||
{
|
||||
myCurve.D1(U, P, V);
|
||||
myTrsf.TransformD1(P, V);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : D2
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void GEOMUtils::TrsfCurve2d::D2(const Standard_Real U, gp_Pnt2d &P,
|
||||
gp_Vec2d &V1, gp_Vec2d &V2) const
|
||||
{
|
||||
myCurve.D2(U, P, V1, V2);
|
||||
myTrsf.TransformD2(P, V1, V2);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : D3
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void GEOMUtils::TrsfCurve2d::D3(const Standard_Real U, gp_Pnt2d &P,
|
||||
gp_Vec2d &V1, gp_Vec2d &V2, gp_Vec2d &V3) const
|
||||
{
|
||||
myCurve.D3(U, P, V1, V2, V3);
|
||||
myTrsf.TransformD3(P, V1, V2, V3);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DN
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
gp_Vec2d GEOMUtils::TrsfCurve2d::DN(const Standard_Real U,
|
||||
const Standard_Integer N) const
|
||||
{
|
||||
gp_Pnt2d aPnt = myCurve.Value(U);
|
||||
gp_Vec2d aVec = myCurve.DN(U, N);
|
||||
|
||||
myTrsf.TransformD1(aPnt, aVec);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Resolution
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Real GEOMUtils::TrsfCurve2d::Resolution(const Standard_Real Ruv) const
|
||||
{
|
||||
return Precision::Parametric(Ruv);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Line
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
gp_Lin2d GEOMUtils::TrsfCurve2d::Line() const
|
||||
{
|
||||
Standard_NoSuchObject::Raise();
|
||||
|
||||
return gp_Lin2d();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Circle
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
gp_Circ2d GEOMUtils::TrsfCurve2d::Circle() const
|
||||
{
|
||||
Standard_NoSuchObject::Raise();
|
||||
|
||||
return gp_Circ2d();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Ellipse
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
gp_Elips2d GEOMUtils::TrsfCurve2d::Ellipse() const
|
||||
{
|
||||
Standard_NoSuchObject::Raise();
|
||||
|
||||
return gp_Elips2d();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Hyperbola
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
gp_Hypr2d GEOMUtils::TrsfCurve2d::Hyperbola() const
|
||||
{
|
||||
Standard_NoSuchObject::Raise();
|
||||
|
||||
return gp_Hypr2d();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Parabola
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
gp_Parab2d GEOMUtils::TrsfCurve2d::Parabola() const
|
||||
{
|
||||
Standard_NoSuchObject::Raise();
|
||||
|
||||
return gp_Parab2d();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Degree
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Integer GEOMUtils::TrsfCurve2d::Degree() const
|
||||
{
|
||||
Standard_NoSuchObject::Raise();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsRational
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean GEOMUtils::TrsfCurve2d::IsRational() const
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NbPoles
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Integer GEOMUtils::TrsfCurve2d::NbPoles() const
|
||||
{
|
||||
Standard_NoSuchObject::Raise();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NbKnots
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Integer GEOMUtils::TrsfCurve2d::NbKnots() const
|
||||
{
|
||||
Standard_NoSuchObject::Raise();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Bezier
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(Geom2d_BezierCurve) GEOMUtils::TrsfCurve2d::Bezier() const
|
||||
{
|
||||
Standard_NoSuchObject::Raise();
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BSpline
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(Geom2d_BSplineCurve) GEOMUtils::TrsfCurve2d::BSpline() const
|
||||
{
|
||||
Standard_NoSuchObject::Raise();
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NbSamples
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Integer GEOMUtils::TrsfCurve2d::NbSamples() const
|
||||
{
|
||||
return myCurve.NbSamples();
|
||||
}
|
242
src/GEOMUtils/GEOMUtils_TrsfCurve2d.hxx
Normal file
242
src/GEOMUtils/GEOMUtils_TrsfCurve2d.hxx
Normal file
@ -0,0 +1,242 @@
|
||||
// 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
|
||||
//
|
||||
|
||||
#ifndef _GEOMUtils_TrsfCurve2d_HXX_
|
||||
#define _GEOMUtils_TrsfCurve2d_HXX_
|
||||
|
||||
|
||||
#include <GEOMUtils_Trsf2d.hxx>
|
||||
|
||||
#include <Geom2dHatch_Hatcher.hxx>
|
||||
#include <GeomAbs_IsoType.hxx>
|
||||
#include <TColStd_HArray1OfInteger.hxx>
|
||||
#include <TColStd_HArray1OfReal.hxx>
|
||||
#include <TopoDS_Face.hxx>
|
||||
|
||||
|
||||
namespace GEOMUtils
|
||||
{
|
||||
/*!
|
||||
* This class represents an adaptor curve that represents an original curve
|
||||
* transformed by an anisotropic transformation.
|
||||
*/
|
||||
class TrsfCurve2d : public Adaptor2d_Curve2d
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor. Initializes the object with the transformation parameters.
|
||||
* Input parameters are not checked for validity. It is under responsibility
|
||||
* of the caller.
|
||||
*/
|
||||
Standard_EXPORT TrsfCurve2d(const Handle(Geom2d_Curve) &theCurve,
|
||||
const Trsf2d &theTrsf);
|
||||
|
||||
/**
|
||||
* Constructor. Initializes the object with the curve, first and last
|
||||
* parameters and transformation. Input parameters are not checked
|
||||
* for validity. It is under responsibility of the caller.
|
||||
*/
|
||||
Standard_EXPORT TrsfCurve2d(const Handle(Geom2d_Curve) &theCurve,
|
||||
const Standard_Real theUFirst,
|
||||
const Standard_Real theULast,
|
||||
const Trsf2d &theTrsf);
|
||||
|
||||
/**
|
||||
* Redefined method from the base class.
|
||||
*/
|
||||
Standard_EXPORT Standard_Real FirstParameter() const;
|
||||
|
||||
/**
|
||||
* Redefined method from the base class.
|
||||
*/
|
||||
Standard_EXPORT Standard_Real LastParameter() const;
|
||||
|
||||
/**
|
||||
* Redefined method from the base class.
|
||||
*/
|
||||
Standard_EXPORT const Handle(Geom2d_Curve)& Curve() const;
|
||||
|
||||
/**
|
||||
* Redefined method from the base class.
|
||||
*/
|
||||
Standard_EXPORT GeomAbs_CurveType GetType() const;
|
||||
|
||||
/**
|
||||
* Redefined method from the base class.
|
||||
*/
|
||||
Standard_EXPORT void Load(const Handle(Geom2d_Curve) &C);
|
||||
|
||||
/**
|
||||
* Redefined method from the base class.
|
||||
*/
|
||||
Standard_EXPORT void Load(const Handle(Geom2d_Curve) &C,
|
||||
const Standard_Real UFirst,
|
||||
const Standard_Real ULast);
|
||||
|
||||
/**
|
||||
* Redefined method from the base class.
|
||||
*/
|
||||
Standard_EXPORT GeomAbs_Shape Continuity() const;
|
||||
|
||||
/**
|
||||
* Redefined method from the base class.
|
||||
*/
|
||||
Standard_EXPORT Standard_Integer NbIntervals(const GeomAbs_Shape S) const;
|
||||
|
||||
/**
|
||||
* Redefined method from the base class.
|
||||
*/
|
||||
Standard_EXPORT void Intervals(TColStd_Array1OfReal &T,
|
||||
const GeomAbs_Shape S) const;
|
||||
|
||||
/**
|
||||
* Redefined method from the base class.
|
||||
*/
|
||||
Standard_EXPORT Handle(Adaptor2d_HCurve2d) Trim
|
||||
(const Standard_Real First, const Standard_Real Last,
|
||||
const Standard_Real ) const;
|
||||
|
||||
/**
|
||||
* Redefined method from the base class.
|
||||
*/
|
||||
Standard_EXPORT Standard_Boolean IsClosed() const;
|
||||
|
||||
/**
|
||||
* Redefined method from the base class.
|
||||
*/
|
||||
Standard_EXPORT Standard_Boolean IsPeriodic() const;
|
||||
|
||||
/**
|
||||
* Redefined method from the base class.
|
||||
*/
|
||||
Standard_EXPORT Standard_Real Period() const;
|
||||
|
||||
/**
|
||||
* Redefined method from the base class.
|
||||
*/
|
||||
Standard_EXPORT gp_Pnt2d Value(const Standard_Real U) const;
|
||||
|
||||
/**
|
||||
* Redefined method from the base class.
|
||||
*/
|
||||
Standard_EXPORT void D0(const Standard_Real U, gp_Pnt2d &P) const;
|
||||
|
||||
/**
|
||||
* Redefined method from the base class.
|
||||
*/
|
||||
Standard_EXPORT void D1(const Standard_Real U,
|
||||
gp_Pnt2d &P, gp_Vec2d &V) const;
|
||||
|
||||
/**
|
||||
* Redefined method from the base class.
|
||||
*/
|
||||
Standard_EXPORT void D2(const Standard_Real U, gp_Pnt2d &P,
|
||||
gp_Vec2d &V1, gp_Vec2d &V2) const;
|
||||
|
||||
/**
|
||||
* Redefined method from the base class.
|
||||
*/
|
||||
Standard_EXPORT void D3(const Standard_Real U, gp_Pnt2d &P,
|
||||
gp_Vec2d &V1, gp_Vec2d &V2, gp_Vec2d &V3) const;
|
||||
|
||||
/**
|
||||
* Redefined method from the base class.
|
||||
*/
|
||||
Standard_EXPORT gp_Vec2d DN(const Standard_Real U,
|
||||
const Standard_Integer N) const;
|
||||
|
||||
/**
|
||||
* Redefined method from the base class.
|
||||
*/
|
||||
Standard_EXPORT Standard_Real Resolution(const Standard_Real Ruv) const;
|
||||
|
||||
/**
|
||||
* Redefined method from the base class.
|
||||
*/
|
||||
Standard_EXPORT gp_Lin2d Line() const;
|
||||
|
||||
/**
|
||||
* Redefined method from the base class.
|
||||
*/
|
||||
Standard_EXPORT gp_Circ2d Circle() const;
|
||||
|
||||
/**
|
||||
* Redefined method from the base class.
|
||||
*/
|
||||
Standard_EXPORT gp_Elips2d Ellipse() const;
|
||||
|
||||
/**
|
||||
* Redefined method from the base class.
|
||||
*/
|
||||
Standard_EXPORT gp_Hypr2d Hyperbola() const;
|
||||
|
||||
/**
|
||||
* Redefined method from the base class.
|
||||
*/
|
||||
Standard_EXPORT gp_Parab2d Parabola() const;
|
||||
|
||||
/**
|
||||
* Redefined method from the base class.
|
||||
*/
|
||||
Standard_EXPORT Standard_Integer Degree() const;
|
||||
|
||||
/**
|
||||
* Redefined method from the base class.
|
||||
*/
|
||||
Standard_EXPORT Standard_Boolean IsRational() const;
|
||||
|
||||
/**
|
||||
* Redefined method from the base class.
|
||||
*/
|
||||
Standard_EXPORT Standard_Integer NbPoles() const;
|
||||
|
||||
/**
|
||||
* Redefined method from the base class.
|
||||
*/
|
||||
Standard_EXPORT Standard_Integer NbKnots() const;
|
||||
|
||||
/**
|
||||
* Redefined method from the base class.
|
||||
*/
|
||||
Standard_EXPORT Handle(Geom2d_BezierCurve) Bezier() const;
|
||||
|
||||
/**
|
||||
* Redefined method from the base class.
|
||||
*/
|
||||
Standard_EXPORT Handle(Geom2d_BSplineCurve) BSpline() const;
|
||||
|
||||
/**
|
||||
* Redefined method from the base class.
|
||||
*/
|
||||
Standard_EXPORT Standard_Integer NbSamples() const;
|
||||
|
||||
private:
|
||||
|
||||
Geom2dAdaptor_Curve myCurve;
|
||||
Trsf2d myTrsf;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -1392,3 +1392,37 @@ GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::RecomputeObject
|
||||
|
||||
return aGEOMObject._retn();
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* MakeProjectionOnCylinder
|
||||
*/
|
||||
//=============================================================================
|
||||
GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MakeProjectionOnCylinder
|
||||
(GEOM::GEOM_Object_ptr theObject,
|
||||
CORBA::Double theRadius,
|
||||
CORBA::Double theStartAngle,
|
||||
CORBA::Double theAngleLength)
|
||||
{
|
||||
GEOM::GEOM_Object_var aGEOMObject;
|
||||
|
||||
//Set a not done flag
|
||||
GetOperations()->SetNotDone();
|
||||
|
||||
//Get the object
|
||||
Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
|
||||
|
||||
if (anObject.IsNull()) {
|
||||
return aGEOMObject._retn();
|
||||
}
|
||||
|
||||
//Perform the transformation
|
||||
Handle(GEOM_Object) aResObject = GetOperations()->MakeProjectionOnCylinder
|
||||
(anObject, theRadius, theStartAngle, theAngleLength);
|
||||
|
||||
if (!GetOperations()->IsDone() || aResObject.IsNull()) {
|
||||
return aGEOMObject._retn();
|
||||
}
|
||||
|
||||
return GetObject(aResObject);
|
||||
}
|
||||
|
@ -197,6 +197,11 @@ class GEOM_I_EXPORT GEOM_ITransformOperations_i :
|
||||
|
||||
GEOM::GEOM_Object_ptr RecomputeObject (GEOM::GEOM_Object_ptr theObject);
|
||||
|
||||
GEOM::GEOM_Object_ptr MakeProjectionOnCylinder
|
||||
(GEOM::GEOM_Object_ptr theObject,
|
||||
CORBA::Double theRadius,
|
||||
CORBA::Double theStartAngle,
|
||||
CORBA::Double theAngleLength);
|
||||
|
||||
::GEOMImpl_ITransformOperations* GetOperations() { return (::GEOMImpl_ITransformOperations*)GetImpl(); }
|
||||
};
|
||||
|
65
src/GEOM_SWIG/geomBuilder.py
Executable file → Normal file
65
src/GEOM_SWIG/geomBuilder.py
Executable file → Normal file
@ -9347,6 +9347,71 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
|
||||
anObj = self.MultiRotate2DByStep(aShape, aVec, anAngle, nbtimes1, aStep, nbtimes2, theName)
|
||||
return anObj
|
||||
|
||||
##
|
||||
# Compute a wire or a face or a compound of faces that represents
|
||||
# a projection of the source shape onto cylinder. The cylinder's
|
||||
# coordinate system is the same as the global coordinate system.
|
||||
#
|
||||
# @param theObject The object to be projected. It can be either
|
||||
# a planar wire or a face.
|
||||
# @param theRadius The radius of the cylinder.
|
||||
# @param theStartAngle The starting angle in radians from
|
||||
# the cylinder's X axis around Z axis. The angle from which
|
||||
# the projection is started.
|
||||
# @param theAngleLength The projection length angle in radians.
|
||||
# The angle in which to project the total length of the wire.
|
||||
# If it is negative the projection is not scaled and natural
|
||||
# wire length is kept for the projection.
|
||||
# @param theName Object name; when specified, this parameter is used
|
||||
# for result publication in the study. Otherwise, if automatic
|
||||
# publication is switched on, default value is used for result name.
|
||||
#
|
||||
# @return New GEOM.GEOM_Object, containing the result shape. The result
|
||||
# represents a wire or a face or a compound of faces that
|
||||
# represents a projection of the source shape onto a cylinder.
|
||||
#
|
||||
# @ref tui_fillet "Example 1"
|
||||
# \n @ref swig_MakeFilletAll "Example 2"
|
||||
def MakeProjectionOnCylinder (self, theObject, theRadius,
|
||||
theStartAngle=0.0, theAngleLength=-1.0,
|
||||
theName=None):
|
||||
"""
|
||||
Compute a wire or a face or a compound of faces that represents
|
||||
a projection of the source shape onto cylinder. The cylinder's
|
||||
coordinate system is the same as the global coordinate system.
|
||||
|
||||
Parameters:
|
||||
theObject The object to be projected. It can be either
|
||||
a planar wire or a face.
|
||||
theRadius The radius of the cylinder.
|
||||
theStartAngle The starting angle in radians from the cylinder's X axis
|
||||
around Z axis. The angle from which the projection is started.
|
||||
theAngleLength The projection length angle in radians. The angle in which
|
||||
to project the total length of the wire. If it is negative the
|
||||
projection is not scaled and natural wire length is kept for
|
||||
the projection.
|
||||
theName Object name; when specified, this parameter is used
|
||||
for result publication in the study. Otherwise, if automatic
|
||||
publication is switched on, default value is used for result name.
|
||||
|
||||
Returns:
|
||||
New GEOM.GEOM_Object, containing the result shape. The result
|
||||
represents a wire or a face or a compound of faces that
|
||||
represents a projection of the source shape onto a cylinder.
|
||||
|
||||
Example of usage:
|
||||
filletall = geompy.MakeFilletAll(prism, 10.)
|
||||
"""
|
||||
# Example: see GEOM_TestOthers.py
|
||||
theRadius, theStartAngle, theAngleLength, Parameters = ParseParameters(
|
||||
theRadius, theStartAngle, theAngleLength)
|
||||
anObj = self.TrsfOp.MakeProjectionOnCylinder(theObject, theRadius,
|
||||
theStartAngle, theAngleLength)
|
||||
RaiseIfFailed("MakeProjectionOnCylinder", self.TrsfOp)
|
||||
anObj.SetParameters(Parameters)
|
||||
self._autoPublish(anObj, theName, "projection")
|
||||
return anObj
|
||||
|
||||
# end of l3_transform
|
||||
## @}
|
||||
|
||||
|
@ -75,6 +75,7 @@ SET(TransformationGUI_HEADERS
|
||||
TransformationGUI_ScaleDlg.h
|
||||
TransformationGUI_OffsetDlg.h
|
||||
TransformationGUI_ProjectionDlg.h
|
||||
TransformationGUI_ProjectionOnCylDlg.h
|
||||
TransformationGUI_PositionDlg.h
|
||||
)
|
||||
|
||||
@ -89,6 +90,7 @@ SET(_moc_HEADERS
|
||||
TransformationGUI_ScaleDlg.h
|
||||
TransformationGUI_OffsetDlg.h
|
||||
TransformationGUI_ProjectionDlg.h
|
||||
TransformationGUI_ProjectionOnCylDlg.h
|
||||
TransformationGUI_PositionDlg.h
|
||||
)
|
||||
|
||||
@ -111,6 +113,7 @@ SET(TransformationGUI_SOURCES
|
||||
TransformationGUI_ScaleDlg.cxx
|
||||
TransformationGUI_OffsetDlg.cxx
|
||||
TransformationGUI_ProjectionDlg.cxx
|
||||
TransformationGUI_ProjectionOnCylDlg.cxx
|
||||
TransformationGUI_PositionDlg.cxx
|
||||
${_moc_SOURCES}
|
||||
${_uic_files}
|
||||
|
@ -49,6 +49,7 @@
|
||||
#include "TransformationGUI_OffsetDlg.h" // Method OFFSET
|
||||
#include "TransformationGUI_ProjectionDlg.h" // Method PROJECTION
|
||||
#include "TransformationGUI_PositionDlg.h" // Method POSITION
|
||||
#include "TransformationGUI_ProjectionOnCylDlg.h" // Method PROJECTION ON CYLINDER
|
||||
|
||||
//=======================================================================
|
||||
// function : TransformationGUI()
|
||||
@ -102,6 +103,9 @@ bool TransformationGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent )
|
||||
case GEOMOp::OpProjection: // PROJECTION
|
||||
aDlg = new TransformationGUI_ProjectionDlg( getGeometryGUI(), parent );
|
||||
break;
|
||||
case GEOMOp::OpProjOnCyl: // PROJECTION ON CYLINDER
|
||||
aDlg = new TransformationGUI_ProjectionOnCylDlg( getGeometryGUI(), parent );
|
||||
break;
|
||||
case GEOMOp::OpMultiTranslate: // MULTI TRANSLATION
|
||||
aDlg = new TransformationGUI_MultiTranslationDlg( getGeometryGUI(), parent );
|
||||
break;
|
||||
|
360
src/TransformationGUI/TransformationGUI_ProjectionOnCylDlg.cxx
Normal file
360
src/TransformationGUI/TransformationGUI_ProjectionOnCylDlg.cxx
Normal file
@ -0,0 +1,360 @@
|
||||
// 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
|
||||
//
|
||||
|
||||
// GEOM GEOMGUI : GUI for Geometry component
|
||||
// File : TransformationGUI_ProjectionOnCylDlg.cxx
|
||||
// Author : Sergey KHROMOV, Open CASCADE S.A.S.
|
||||
|
||||
#include "TransformationGUI_ProjectionOnCylDlg.h"
|
||||
|
||||
#include <GeometryGUI.h>
|
||||
#include <GEOMBase.h>
|
||||
#include <GEOMImpl_Types.hxx>
|
||||
|
||||
#include <SUIT_Session.h>
|
||||
#include <SUIT_ResourceMgr.h>
|
||||
#include <SalomeApp_Application.h>
|
||||
#include <SalomeApp_DoubleSpinBox.h>
|
||||
#include <LightApp_SelectionMgr.h>
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QGridLayout>
|
||||
#include <QGroupBox>
|
||||
#include <QLineEdit>
|
||||
#include <QPushButton>
|
||||
#include <QRadioButton>
|
||||
|
||||
#include <TColStd_MapOfInteger.hxx>
|
||||
|
||||
//=================================================================================
|
||||
// class : TransformationGUI_ProjectionOnCylDlg()
|
||||
// purpose : Constructs a TransformationGUI_ProjectionOnCylDlg which is
|
||||
// a child of 'parent', with the name 'name' and widget flags set to
|
||||
// 'f'. The dialog will by default be modeless, unless you set
|
||||
// 'modal' to TRUE to construct a modal dialog.
|
||||
//=================================================================================
|
||||
TransformationGUI_ProjectionOnCylDlg::TransformationGUI_ProjectionOnCylDlg
|
||||
(GeometryGUI* theGeometryGUI, QWidget* parent, bool modal, Qt::WindowFlags fl)
|
||||
: GEOMBase_Skeleton (theGeometryGUI, parent, modal, fl),
|
||||
myObjectName (0),
|
||||
mySelButton (0),
|
||||
myRadiusSpin (0),
|
||||
myStartAngleSpin (0),
|
||||
myUseAngleLen (0),
|
||||
myAngleLenSpin (0)
|
||||
{
|
||||
SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr();
|
||||
QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICO_DLG_PROJ_ON_CYL")));
|
||||
QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
|
||||
|
||||
setWindowTitle(tr("GEOM_PROJ_ON_CYL_TITLE"));
|
||||
|
||||
/***************************************************************/
|
||||
mainFrame()->GroupConstructors->setTitle(tr("GEOM_PROJECTION_TITLE"));
|
||||
mainFrame()->RadioButton1->setIcon(image0);
|
||||
mainFrame()->RadioButton2->setAttribute(Qt::WA_DeleteOnClose);
|
||||
mainFrame()->RadioButton2->close();
|
||||
mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
|
||||
mainFrame()->RadioButton3->close();
|
||||
|
||||
QGroupBox *aGrpParams =
|
||||
new QGroupBox(tr("GEOM_ARGUMENTS"), centralWidget());
|
||||
QGridLayout *aParamsLayout = new QGridLayout(aGrpParams);
|
||||
QLabel *anObjLbl = new QLabel(tr("GEOM_OBJECT"), aGrpParams);
|
||||
QLabel *aRadiusLbl = new QLabel(tr("GEOM_RADIUS"), aGrpParams);
|
||||
QLabel *aStartAngleLbl =
|
||||
new QLabel(tr("GEOM_PROJ_ON_CYL_START_ANGLE"), aGrpParams);
|
||||
QLabel *anAngleLenLbl =
|
||||
new QLabel(tr("GEOM_PROJ_ON_CYL_LENGTH_ANGLE"), aGrpParams);
|
||||
|
||||
myObjectName = new QLineEdit(aGrpParams);
|
||||
mySelButton = new QPushButton(aGrpParams);
|
||||
myRadiusSpin = new SalomeApp_DoubleSpinBox(aGrpParams);
|
||||
myStartAngleSpin = new SalomeApp_DoubleSpinBox(aGrpParams);
|
||||
myUseAngleLen = new QCheckBox(aGrpParams);
|
||||
myAngleLenSpin = new SalomeApp_DoubleSpinBox(aGrpParams);
|
||||
|
||||
myObjectName->setReadOnly(true);
|
||||
mySelButton->setIcon(image1);
|
||||
mySelButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
myUseAngleLen->setChecked(false);
|
||||
|
||||
aParamsLayout->setMargin(9);
|
||||
aParamsLayout->setSpacing(6);
|
||||
aParamsLayout->addWidget(anObjLbl, 0, 1);
|
||||
aParamsLayout->addWidget(mySelButton, 0, 2);
|
||||
aParamsLayout->addWidget(myObjectName, 0, 3);
|
||||
aParamsLayout->addWidget(aRadiusLbl, 1, 1);
|
||||
aParamsLayout->addWidget(myRadiusSpin, 1, 2, 1, 2);
|
||||
aParamsLayout->addWidget(aStartAngleLbl, 2, 1);
|
||||
aParamsLayout->addWidget(myStartAngleSpin, 2, 2, 1, 2);
|
||||
aParamsLayout->addWidget(myUseAngleLen, 3, 0);
|
||||
aParamsLayout->addWidget(anAngleLenLbl, 3, 1);
|
||||
aParamsLayout->addWidget(myAngleLenSpin, 3, 2, 1, 2);
|
||||
|
||||
QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
|
||||
layout->setMargin( 0 ); layout->setSpacing( 6 );
|
||||
layout->addWidget( aGrpParams );
|
||||
|
||||
/***************************************************************/
|
||||
|
||||
setHelpFileName("project_on_cylinder_operation_page.html");
|
||||
|
||||
Init();
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : ~TransformationGUI_ProjectionOnCylDlg()
|
||||
// purpose : Destroys the object and frees any allocated resources
|
||||
//=================================================================================
|
||||
TransformationGUI_ProjectionOnCylDlg::~TransformationGUI_ProjectionOnCylDlg()
|
||||
{
|
||||
// no need to delete child widgets, Qt does it all for us
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : Init()
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void TransformationGUI_ProjectionOnCylDlg::Init()
|
||||
{
|
||||
showOnlyPreviewControl();
|
||||
|
||||
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
|
||||
double aStep = resMgr->doubleValue("Geometry", "SettingsGeomStep", 100);
|
||||
double aSpecificStep = 5;
|
||||
double aRadius = 100.0;
|
||||
double aStartAngle = 0.;
|
||||
double anAngleLen = 360.;
|
||||
|
||||
initSpinBox(myRadiusSpin, 0.00001, COORD_MAX, aStep, "length_precision");
|
||||
initSpinBox(myStartAngleSpin, -180., 180., aSpecificStep, "angle_precision");
|
||||
initSpinBox(myAngleLenSpin, 0.00001, COORD_MAX, aSpecificStep, "angle_precision");
|
||||
|
||||
myRadiusSpin->setValue(aRadius);
|
||||
myStartAngleSpin->setValue(aStartAngle);
|
||||
myAngleLenSpin->setValue(anAngleLen);
|
||||
|
||||
myObjectName->setText("");
|
||||
myUseAngleLen->setChecked(true);
|
||||
|
||||
// signals and slots connections
|
||||
connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
|
||||
connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
|
||||
|
||||
connect(mySelButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
|
||||
connect(myRadiusSpin, SIGNAL(valueChanged(double)), this, SLOT(processPreview()));
|
||||
connect(myStartAngleSpin, SIGNAL(valueChanged(double)), this, SLOT(processPreview()));
|
||||
connect(myAngleLenSpin, SIGNAL(valueChanged(double)), this, SLOT(processPreview()));
|
||||
connect(myUseAngleLen, SIGNAL(clicked()), this, SLOT(SetUseLengthAngle()));
|
||||
|
||||
connect(myGeomGUI->getApp()->selectionMgr(),SIGNAL(currentSelectionChanged()),
|
||||
this, SLOT(SelectionIntoArgument()));
|
||||
|
||||
initName(tr("GEOM_PROJECTION_NAME"));
|
||||
|
||||
buttonOk()->setEnabled(false);
|
||||
buttonApply()->setEnabled(false);
|
||||
|
||||
activateSelection();
|
||||
SelectionIntoArgument();
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : ClickOnOk()
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void TransformationGUI_ProjectionOnCylDlg::ClickOnOk()
|
||||
{
|
||||
setIsApplyAndClose( true );
|
||||
if (ClickOnApply())
|
||||
ClickOnCancel();
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : ClickOnApply()
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
bool TransformationGUI_ProjectionOnCylDlg::ClickOnApply()
|
||||
{
|
||||
if ( !onAccept() )
|
||||
return false;
|
||||
|
||||
initName();
|
||||
return true;
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : SelectionIntoArgument()
|
||||
// purpose : Called when selection is changed or on dialog initialization or activation
|
||||
//=================================================================================
|
||||
void TransformationGUI_ProjectionOnCylDlg::SelectionIntoArgument()
|
||||
{
|
||||
erasePreview();
|
||||
myObj = GEOM::GEOM_Object::_nil();
|
||||
|
||||
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
|
||||
SALOME_ListIO aSelList;
|
||||
aSelMgr->selectedObjects(aSelList);
|
||||
|
||||
if (aSelList.Extent() == 1) {
|
||||
// Single object is selected.
|
||||
GEOM::GEOM_Object_var aSelectedObject =
|
||||
GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
|
||||
|
||||
if (aSelectedObject->_is_nil()) {
|
||||
// Null object.
|
||||
myObjectName->setText("");
|
||||
buttonOk()->setEnabled(false);
|
||||
buttonApply()->setEnabled(false);
|
||||
} else {
|
||||
// Not Null object.
|
||||
myObj = aSelectedObject;
|
||||
myObjectName->setText(GEOMBase::GetName(myObj));
|
||||
buttonOk()->setEnabled(true);
|
||||
buttonApply()->setEnabled(true);
|
||||
}
|
||||
} else {
|
||||
// Not a single object is selected.
|
||||
myObjectName->setText("");
|
||||
buttonOk()->setEnabled(false);
|
||||
buttonApply()->setEnabled(false);
|
||||
}
|
||||
|
||||
processPreview();
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : SetEditCurrentArgument()
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void TransformationGUI_ProjectionOnCylDlg::SetEditCurrentArgument()
|
||||
{
|
||||
myObjectName->setFocus();
|
||||
myEditCurrentArgument = myObjectName;
|
||||
SelectionIntoArgument();
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : SetUseLengthAngle()
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void TransformationGUI_ProjectionOnCylDlg::SetUseLengthAngle()
|
||||
{
|
||||
myAngleLenSpin->setEnabled(myUseAngleLen->isChecked());
|
||||
processPreview();
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : activateSelection
|
||||
// purpose : activate selection of wires or faces
|
||||
//=================================================================================
|
||||
void TransformationGUI_ProjectionOnCylDlg::activateSelection()
|
||||
{
|
||||
TColStd_MapOfInteger aMap;
|
||||
|
||||
aMap.Add(GEOM_WIRE);
|
||||
aMap.Add(GEOM_FACE);
|
||||
globalSelection(aMap);
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : ActivateThisDialog()
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void TransformationGUI_ProjectionOnCylDlg::ActivateThisDialog()
|
||||
{
|
||||
GEOMBase_Skeleton::ActivateThisDialog();
|
||||
connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
|
||||
this, SLOT( SelectionIntoArgument() ) );
|
||||
|
||||
activateSelection();
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : enterEvent()
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void TransformationGUI_ProjectionOnCylDlg::enterEvent (QEvent*)
|
||||
{
|
||||
if (!mainFrame()->GroupConstructors->isEnabled())
|
||||
ActivateThisDialog();
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : createOperation
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
GEOM::GEOM_IOperations_ptr TransformationGUI_ProjectionOnCylDlg::createOperation()
|
||||
{
|
||||
return getGeomEngine()->GetITransformOperations(getStudyId());
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : isValid
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
bool TransformationGUI_ProjectionOnCylDlg::isValid (QString &msg)
|
||||
{
|
||||
bool isOk = false;
|
||||
|
||||
if (!myObj->_is_nil() &&
|
||||
myRadiusSpin->isValid(msg, !IsPreview()) &&
|
||||
myStartAngleSpin->isValid(msg, !IsPreview())) {
|
||||
if (myUseAngleLen->isChecked()) {
|
||||
// Check length angle spin.
|
||||
isOk = myAngleLenSpin->isValid(msg, !IsPreview());
|
||||
} else {
|
||||
// Don't check length angle spin.
|
||||
isOk = true;
|
||||
}
|
||||
}
|
||||
|
||||
return isOk;
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : execute
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
bool TransformationGUI_ProjectionOnCylDlg::execute (ObjectList& objects)
|
||||
{
|
||||
GEOM::GEOM_ITransformOperations_var anOper =
|
||||
GEOM::GEOM_ITransformOperations::_narrow(getOperation());
|
||||
|
||||
double aRadius = myRadiusSpin->value();
|
||||
double aStartAngle = myStartAngleSpin->value()*M_PI/180.;
|
||||
double aLengthAngle = -1.;
|
||||
|
||||
if (myUseAngleLen->isChecked()) {
|
||||
aLengthAngle = myAngleLenSpin->value()*M_PI/180.;
|
||||
}
|
||||
|
||||
GEOM::GEOM_Object_var anObj = anOper->MakeProjectionOnCylinder
|
||||
(myObj, aRadius, aStartAngle, aLengthAngle);
|
||||
|
||||
if (!anObj->_is_nil()) {
|
||||
objects.push_back(anObj._retn());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
78
src/TransformationGUI/TransformationGUI_ProjectionOnCylDlg.h
Normal file
78
src/TransformationGUI/TransformationGUI_ProjectionOnCylDlg.h
Normal file
@ -0,0 +1,78 @@
|
||||
// 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
|
||||
//
|
||||
|
||||
// GEOM GEOMGUI : GUI for Geometry component
|
||||
// File : TransformationGUI_ProjectionOnCylDlg.h
|
||||
// Author : Sergey KHROMOV, Open CASCADE S.A.S.
|
||||
//
|
||||
#ifndef TRANSFORMATIONGUI_PROJECTIONONCYLDLG_H
|
||||
#define TRANSFORMATIONGUI_PROJECTIONONCYLDLG_H
|
||||
|
||||
|
||||
#include "GEOMBase_Skeleton.h"
|
||||
|
||||
|
||||
//=================================================================================
|
||||
// class : TransformationGUI_ProjectionOnCylDlg
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
class TransformationGUI_ProjectionOnCylDlg : public GEOMBase_Skeleton
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TransformationGUI_ProjectionOnCylDlg(GeometryGUI*, QWidget* = 0,
|
||||
bool = false, Qt::WindowFlags = 0);
|
||||
~TransformationGUI_ProjectionOnCylDlg();
|
||||
|
||||
protected:
|
||||
// redefined from GEOMBase_Helper
|
||||
virtual GEOM::GEOM_IOperations_ptr createOperation();
|
||||
virtual bool isValid(QString &msg);
|
||||
virtual bool execute(ObjectList &);
|
||||
|
||||
private:
|
||||
void Init();
|
||||
void enterEvent( QEvent* );
|
||||
void activateSelection();
|
||||
|
||||
private slots:
|
||||
void ClickOnOk();
|
||||
bool ClickOnApply();
|
||||
void ActivateThisDialog();
|
||||
void SelectionIntoArgument();
|
||||
void SetEditCurrentArgument();
|
||||
void SetUseLengthAngle();
|
||||
|
||||
private:
|
||||
|
||||
GEOM::GEOM_Object_var myObj;
|
||||
QLineEdit *myObjectName;
|
||||
QPushButton *mySelButton;
|
||||
SalomeApp_DoubleSpinBox *myRadiusSpin;
|
||||
SalomeApp_DoubleSpinBox *myStartAngleSpin;
|
||||
QCheckBox *myUseAngleLen;
|
||||
SalomeApp_DoubleSpinBox *myAngleLenSpin;
|
||||
|
||||
};
|
||||
|
||||
#endif // TRANSFORMATIONGUI_PROJECTIONONCYLDLG_H
|
Loading…
Reference in New Issue
Block a user