*/
GEOM_Object OffsetShapeCopy (in GEOM_Object theObject, in double theOffset);
+ /*!
+ * Create new object as projection of the given one on a 2D surface.
+ * \param theSource The source object for the projection. It can be a point, edge or wire.
+ * \param theTarget The target object. It can be planar or cylindrical face.
+ * \return New GEOM_Object, containing the projection.
+ */
+ GEOM_Object ProjectShapeCopy (in GEOM_Object theSource, in GEOM_Object theTarget);
+
/*!
* Scale the given object by the factor.
* \param theObject The object to be scaled.
/*!
* Get a sub shape defined by its unique ID inside \a theMainShape
+ * \param theMainShape Main shape.
+ * \param theID Unique ID of sub shape inside \a theMainShape.
+ * \return GEOM_Object, corresponding to found sub shape.
* \note The sub shape GEOM_Objects can has ONLY ONE function.
- * Don't try to apply modification operations on them.
+ * Don't try to apply modification operations (without copy) on them.
*/
GEOM_Object GetSubShape (in GEOM_Object theMainShape,
in long theID);
+ /*!
+ * Get a set of sub shapes defined by their unique IDs inside \a theMainShape
+ * \param theMainShape Main shape.
+ * \param theIndices List of unique IDs of sub shapes inside \a theMainShape.
+ * \return List of GEOM_Objects, corresponding to found sub shapes.
+ * \note The sub shape GEOM_Objects can has ONLY ONE function.
+ * Don't try to apply modification operations (without copy) on them.
+ */
+ ListOfGO MakeSubShapes (in GEOM_Object theMainShape,
+ in ListOfLong theIndices);
+
/*!
* Get global index of \a theSubShape in \a theMainShape.
* \param theMainShape Main shape.
/*!
* Add a sub shape defined by indices in \a theIndices
- * (contains unique IDs of sub shapes inside theMainShape)
+ * (contains unique IDs of sub shapes inside \a theMainShape)
* \note The sub shape GEOM_Objects can has ONLY ONE function.
* Don't try to apply modification operations on them.
* \note Internal method
multitranslationsimple.png \
normale.png \
offset.png \
+projection.png \
origin_and_vectors.png \
partition.png \
partitionkeep.png \
bool EntityGUI_SubShapeDlg::execute (ObjectList& objects)
{
GEOM::GEOM_IShapesOperations_var anOper = GEOM::GEOM_IShapesOperations::_narrow(getOperation());
- //GEOM::ListOfGO_var aList = anOper->ExtractSubShapes(myObject, shapeType(), true);
- GEOM::ListOfGO_var aList = anOper->ExtractSubShapes(myObject, shapeType(), isAllSubShapes());
- if (!aList->length())
- return false;
-
- // Throw away sub-shapes not selected by user if not in preview mode
- // and manual selection is active
if (!isAllSubShapes()) {
+ // manual selection
TColStd_IndexedMapOfInteger aMapIndex;
int nbSel = getSelectedSubshapes(aMapIndex);
if (nbSel > 0) {
- //GEOM::GEOM_ILocalOperations_var aLocOp =
- // getGeomEngine()->GetILocalOperations(getStudyId());
- TopTools_IndexedMapOfShape aSubShapesMap;
- TopExp::MapShapes(myShape, aSubShapesMap);
-
- for (int i = 0, n = aList->length(); i < n; i++) {
- //if (aMapIndex.Contains(aLocOp->GetSubShapeIndex(myObject, aList[i])))
- TopoDS_Shape aSShape = GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), aList[i]);
- if (aMapIndex.Contains(aSubShapesMap.FindIndex(aSShape)))
- objects.push_back(GEOM::GEOM_Object::_duplicate(aList[i]));
- else
- aList[i]->UnRegister();
- }
+ int i;
+
+ GEOM::ListOfLong_var anArray = new GEOM::ListOfLong;
+ anArray->length(nbSel);
+
+ for (i = 1; i <= nbSel; i++)
+ anArray[i - 1] = aMapIndex.FindKey(i);
+
+ GEOM::ListOfGO_var aList = anOper->MakeSubShapes(myObject, anArray);
+ int n = aList->length();
+ for (i = 0; i < n; i++)
+ objects.push_back(GEOM::GEOM_Object::_duplicate(aList[i]));
}
}
else {
+ GEOM::ListOfGO_var aList = anOper->ExtractSubShapes(myObject, shapeType(), true);
+ if (!aList->length())
+ return false;
for (int i = 0, n = aList->length(); i < n; i++)
objects.push_back(GEOM::GEOM_Object::_duplicate(aList[i]));
}
// 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 : GEOMGUI.cxx
// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
-//
+
#include "GEOMGUI.h"
#include "GeometryGUI.h"
{
return myGeometryGUI;
}
-
<source>ICON_DLG_OFFSET</source>
<translation>offset.png</translation>
</message>
+ <message>
+ <source>ICON_DLG_PROJECTION</source>
+ <translation>projection.png</translation>
+ </message>
<message>
<source>ICON_DLG_PARTITION</source>
<translation>partition.png</translation>
<source>ICO_OFFSET</source>
<translation>offset.png</translation>
</message>
+ <message>
+ <source>ICO_PROJECTION</source>
+ <translation>projection.png</translation>
+ </message>
<message>
<source>ICO_ORIGIN_AND_VECTORS</source>
<translation>origin_and_vectors.png</translation>
<source>GEOM_OFFSET_TITLE</source>
<translation>Offset Surface</translation>
</message>
+ <message>
+ <source>GEOM_PROJECTION</source>
+ <translation>Projection</translation>
+ </message>
+ <message>
+ <source>GEOM_PROJECTION_TITLE</source>
+ <translation>Projection on Face</translation>
+ </message>
+ <message>
+ <source>GEOM_SOURCE_OBJECT</source>
+ <translation>Source vertex, edge or wire</translation>
+ </message>
+ <message>
+ <source>GEOM_TARGET_OBJECT</source>
+ <translation>Target face</translation>
+ </message>
<message>
<source>GEOM_OPERATIONS</source>
<translation>Operations</translation>
<source>MEN_OFFSET</source>
<translation>Offset Surface</translation>
</message>
+ <message>
+ <source>MEN_PROJECTION</source>
+ <translation>Projection</translation>
+ </message>
<message>
<source>MEN_OPERATIONS</source>
<translation>Operations</translation>
<source>STB_OFFSET</source>
<translation>Offset surface</translation>
</message>
+ <message>
+ <source>STB_PROJECTION</source>
+ <translation>Project a point, an edge or a wire on a face</translation>
+ </message>
<message>
<source>STB_ORIGIN_AND_VECTORS</source>
<translation>Create an origin and base Vectors</translation>
<source>TOP_OFFSET</source>
<translation>Offset surface</translation>
</message>
+ <message>
+ <source>TOP_PROJECTION</source>
+ <translation>Projection</translation>
+ </message>
<message>
<source>TOP_ORIGIN_AND_VECTORS</source>
<translation>Create an origin and base Vectors</translation>
case GEOMOp::OpMirror: // MENU TRANSFORMATION - MIRROR
case GEOMOp::OpScale: // MENU TRANSFORMATION - SCALE
case GEOMOp::OpOffset: // MENU TRANSFORMATION - OFFSET
+ case GEOMOp::OpProjection: // MENU TRANSFORMATION - PROJECTION
case GEOMOp::OpMultiTranslate: // MENU TRANSFORMATION - MULTI-TRANSLATION
case GEOMOp::OpMultiRotate: // MENU TRANSFORMATION - MULTI-ROTATION
case GEOMOp::OpReimport: // CONTEXT(POPUP) MENU - RELOAD_IMPORTED
createGeomAction( GEOMOp::OpMirror, "MIRROR" );
createGeomAction( GEOMOp::OpScale, "SCALE" );
createGeomAction( GEOMOp::OpOffset, "OFFSET" );
+ createGeomAction( GEOMOp::OpProjection, "PROJECTION" );
createGeomAction( GEOMOp::OpMultiTranslate, "MUL_TRANSLATION" );
createGeomAction( GEOMOp::OpMultiRotate, "MUL_ROTATION" );
createMenu( GEOMOp::OpMirror, transId, -1 );
createMenu( GEOMOp::OpScale, transId, -1 );
createMenu( GEOMOp::OpOffset, transId, -1 );
+ createMenu( GEOMOp::OpProjection, transId, -1 );
createMenu( separator(), transId, -1 );
createMenu( GEOMOp::OpMultiTranslate, transId, -1 );
createMenu( GEOMOp::OpMultiRotate, transId, -1 );
createTool( GEOMOp::OpMirror, transTbId );
createTool( GEOMOp::OpScale, transTbId );
createTool( GEOMOp::OpOffset, transTbId );
+ createTool( GEOMOp::OpProjection, transTbId );
createTool( separator(), transTbId );
createTool( GEOMOp::OpMultiTranslate, transTbId );
createTool( GEOMOp::OpMultiRotate, transTbId );
OpMultiTranslate = 3606, // MENU OPERATIONS - TRANSFORMATION - MULTI-TRANSLATION
OpMultiRotate = 3607, // MENU OPERATIONS - TRANSFORMATION - MULTI-ROTATION
OpReimport = 3608, // POPUP MENU - RELOAD IMPORTED
+ OpProjection = 3609, // MENU OPERATIONS - TRANSFORMATION - PROJECTION
// OperationGUI
OpPartition = 3700, // MENU OPERATION - PARTITION
OpArchimede = 3701, // MENU OPERATION - ARCHIMEDE
// 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 Mirror creation.
-//
+//NOTE: This is an interface to a function for the Mirror creation.
+
#include "GEOM_Function.hxx"
#define MIRROR_ARG_ORIGINAL 1
return anObj;
}
+//=============================================================================
+/*!
+ * MakeSubShapes
+ */
+//=============================================================================
+Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::MakeSubShapes
+ (Handle(GEOM_Object) theMainShape,
+ Handle(TColStd_HArray1OfInteger) theIndices)
+{
+ SetErrorCode(KO);
+
+ Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient;
+
+ if (!theIndices->Length()) {
+ SetErrorCode(NOT_FOUND_ANY);
+ return aSeq;
+ }
+
+ if (theMainShape.IsNull()) return NULL;
+ TopoDS_Shape aShape = theMainShape->GetValue();
+ if (aShape.IsNull()) return NULL;
+
+ Handle(GEOM_Function) aMainShape = theMainShape->GetLastFunction();
+
+ TopTools_IndexedMapOfShape anIndices;
+ TopExp::MapShapes(aShape, anIndices);
+
+ Handle(TColStd_HArray1OfInteger) anArray;
+ Handle(GEOM_Object) anObj;
+
+ TCollection_AsciiString anAsciiList, anEntry;
+ Standard_Integer i, low = theIndices->Lower(), up = theIndices->Upper();
+ for (i = low; i <= up; i++) {
+ int id = theIndices->Value(i);
+ if (1 <= id && id <= anIndices.Extent()) {
+ TopoDS_Shape aValue = anIndices.FindKey(id);
+ anArray = new TColStd_HArray1OfInteger(1,1);
+ anArray->SetValue(1, id);
+
+ anObj = GetEngine()->AddObject(GetDocID(), GEOM_SUBSHAPE);
+ if (!anObj.IsNull()) {
+ Handle(GEOM_Function) aFunction = anObj->AddFunction(GEOM_Object::GetSubShapeID(), 1);
+ if (aFunction.IsNull()) return aSeq;
+
+ GEOM_ISubShape aSSI (aFunction);
+ aSSI.SetMainShape(aMainShape);
+ aSSI.SetIndices(anArray);
+
+ // Set function value directly, as we know it.
+ // Usage of Solver here would lead to significant loss of time,
+ // because GEOM_SubShapeDriver will build TopTools_IndexedMapOfShape
+ // on the main shape for each being calculated sub-shape separately.
+ aFunction->SetValue(aValue);
+
+ // Put this subshape in the list of subshapes of theMainShape
+ aMainShape->AddSubShapeReference(aFunction);
+
+ aSeq->Append(anObj);
+
+ // for python command
+ TDF_Tool::Entry(anObj->GetEntry(), anEntry);
+ anAsciiList += anEntry;
+ anAsciiList += ",";
+ }
+ }
+ }
+
+ //Make a Python command
+ anAsciiList.Trunc(anAsciiList.Length() - 1);
+
+ GEOM::TPythonDump pd (aMainShape, /*append=*/true);
+ pd << "[" << anAsciiList.ToCString() << "] = geompy.SubShapes("
+ << theMainShape << ", [" ;
+ for (i = low; i <= up - 1; i++) {
+ pd << theIndices->Value(i) << ", ";
+ }
+ pd << theIndices->Value(up) << "])";
+
+ SetErrorCode(OK);
+
+ return aSeq;
+}
+
//=============================================================================
/*!
* GetSubShapeIndex
Standard_EXPORT Handle(GEOM_Object) GetSubShape (Handle(GEOM_Object) theMainShape,
const Standard_Integer theID);
+ Standard_EXPORT Handle(TColStd_HSequenceOfTransient) MakeSubShapes
+ (Handle(GEOM_Object) theMainShape,
+ Handle(TColStd_HArray1OfInteger) theIndices);
+
Standard_EXPORT Standard_Integer GetSubShapeIndex (Handle(GEOM_Object) theMainShape,
Handle(GEOM_Object) theSubShape);
}
+//=============================================================================
+/*!
+ * ProjectShapeCopy
+ */
+//=============================================================================
+Handle(GEOM_Object) GEOMImpl_ITransformOperations::ProjectShapeCopy
+ (Handle(GEOM_Object) theSource, Handle(GEOM_Object) theTarget)
+{
+ SetErrorCode(KO);
+
+ if (theSource.IsNull() || theTarget.IsNull()) return NULL;
+
+ Handle(GEOM_Function) aLastFunction = theSource->GetLastFunction();
+ if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be projected
+
+ //Add a new Projection object
+ Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), GEOM_PROJECTION);
+
+ //Add a Projection function
+ Handle(GEOM_Function) aFunction =
+ aCopy->AddFunction(GEOMImpl_MirrorDriver::GetID(), PROJECTION_COPY);
+
+ //Check if the function is set correctly
+ if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
+
+ GEOMImpl_IMirror aTI (aFunction);
+ aTI.SetPlane(theTarget->GetLastFunction());
+ aTI.SetOriginal(aLastFunction);
+
+ //Compute the Projection
+ try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ OCC_CATCH_SIGNALS;
+#endif
+ if (!GetSolver()->ComputeFunction(aFunction)) {
+ SetErrorCode("Projection driver failed");
+ return NULL;
+ }
+ }
+ catch (Standard_Failure) {
+ Handle(Standard_Failure) aFail = Standard_Failure::Caught();
+ SetErrorCode(aFail->GetMessageString());
+ return NULL;
+ }
+
+ //Make a Python command
+ GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeProjection("
+ << theSource << ", " << theTarget << ")";
+
+ SetErrorCode(OK);
+ return aCopy;
+}
+
+
//=============================================================================
/*!
* ScaleShape
Standard_EXPORT Handle(GEOM_Object) OffsetShapeCopy (Handle(GEOM_Object) theObject,
double theOffset);
+ Standard_EXPORT Handle(GEOM_Object) ProjectShapeCopy (Handle(GEOM_Object) theSource,
+ Handle(GEOM_Object) theTarget);
+
Standard_EXPORT Handle(GEOM_Object) ScaleShape (Handle(GEOM_Object) theObject,
Handle(GEOM_Object) thePoint,
double theFactor);
// 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 <Standard_Stream.hxx>
#include <BRep_Tool.hxx>
#include <BRepBuilderAPI_Transform.hxx>
+#include <BRepBuilderAPI_MakeVertex.hxx>
+#include <BRepClass_FaceClassifier.hxx>
+#include <BRepOffsetAPI_NormalProjection.hxx>
+#include <BRepTools.hxx>
#include <TopAbs.hxx>
#include <TopExp.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
+#include <GeomAPI_ProjectPointOnSurf.hxx>
#include <Geom_Plane.hxx>
#include <gp_Trsf.hxx>
TopoDS_Shape anOriginal = anOriginalFunction->GetValue();
if (anOriginal.IsNull()) return 0;
+ // Projection
+ if (aType == PROJECTION_COPY) {
+ // Source shape (point, edge or wire)
+ if (anOriginal.ShapeType() != TopAbs_VERTEX &&
+ anOriginal.ShapeType() != TopAbs_EDGE &&
+ anOriginal.ShapeType() != TopAbs_WIRE) {
+ Standard_ConstructionError::Raise
+ ("Projection aborted : the source shape is neither a vertex, nor an edge or a wire");
+ }
+
+ // Target face
+ Handle(GEOM_Function) aTargetFunction = TI.GetPlane();
+ if (aTargetFunction.IsNull()) return 0;
+ TopoDS_Shape aFaceShape = aTargetFunction->GetValue();
+ //if (aFaceShape.IsNull() || aFaceShape.ShapeType() != TopAbs_FACE) {
+ // Standard_ConstructionError::Raise
+ // ("Projection aborted : the target shape is not a face");
+ //}
+
+ Standard_Real tol = 1.e-4;
+
+ if (anOriginal.ShapeType() == TopAbs_VERTEX) {
+ if (aFaceShape.IsNull() || aFaceShape.ShapeType() != TopAbs_FACE) {
+ Standard_ConstructionError::Raise
+ ("Projection aborted : the target shape is not a face");
+ }
+ TopoDS_Face aFace = TopoDS::Face(aFaceShape);
+ Handle(Geom_Surface) surface = BRep_Tool::Surface(aFace);
+ double U1, U2, V1, V2;
+ //surface->Bounds(U1, U2, V1, V2);
+ BRepTools::UVBounds(aFace, U1, U2, V1, V2);
+
+ // projector
+ GeomAPI_ProjectPointOnSurf proj;
+ proj.Init(surface, U1, U2, V1, V2, tol);
+
+ gp_Pnt aPnt = BRep_Tool::Pnt(TopoDS::Vertex(anOriginal));
+ proj.Perform(aPnt);
+ if (!proj.IsDone()) {
+ Standard_ConstructionError::Raise
+ ("Projection aborted : GeomAPI_ProjectPointOnSurf failed");
+ }
+ int nbPoints = proj.NbPoints();
+ if (nbPoints < 1) {
+ Standard_ConstructionError::Raise("No solution found");
+ }
+
+ Quantity_Parameter U, V;
+ proj.LowerDistanceParameters(U, V);
+ gp_Pnt2d aProjPnt (U, V);
+
+ // classifier
+ BRepClass_FaceClassifier aClsf (aFace, aProjPnt, tol);
+ if (aClsf.State() != TopAbs_IN && aClsf.State() != TopAbs_ON) {
+ bool isSol = false;
+ double minDist = RealLast();
+ for (int i = 1; i <= nbPoints; i++) {
+ Quantity_Parameter Ui, Vi;
+ proj.Parameters(i, Ui, Vi);
+ aProjPnt = gp_Pnt2d(Ui, Vi);
+ aClsf.Perform(aFace, aProjPnt, tol);
+ if (aClsf.State() == TopAbs_IN || aClsf.State() == TopAbs_ON) {
+ isSol = true;
+ double dist = proj.Distance(i);
+ if (dist < minDist) {
+ minDist = dist;
+ U = Ui;
+ V = Vi;
+ }
+ }
+ }
+ if (!isSol) {
+ Standard_ConstructionError::Raise("No solution found");
+ }
+ }
+
+ gp_Pnt surfPnt = surface->Value(U, V);
+
+ aShape = BRepBuilderAPI_MakeVertex(surfPnt).Shape();
+ }
+ else {
+ //see BRepTest_BasicCommands.cxx for example of BRepOffsetAPI_NormalProjection
+ BRepOffsetAPI_NormalProjection OrtProj (aFaceShape);
+ OrtProj.Add(anOriginal);
+
+ //Standard_Real tol = 1.e-4;
+ //Standard_Real tol2d = Pow(tol, 2./3);
+ //GeomAbs_Shape Continuity = GeomAbs_C2;
+ //Standard_Integer MaxDeg = 14;
+ //Standard_Integer MaxSeg = 16;
+ //OrtProj.SetParams(tol, tol2d, Continuity, MaxDeg, MaxSeg);
+ try {
+ OrtProj.Build();
+ } catch (Standard_Failure) {
+ Handle(Standard_Failure) aFail = Standard_Failure::Caught();
+ TCollection_AsciiString aMsg (aFail->GetMessageString());
+ if (!aMsg.Length())
+ aMsg = "Projection aborted : possibly the source shape intersects the cylinder's axis";
+ Standard_ConstructionError::Raise(aMsg.ToCString());
+ }
+ if (!OrtProj.IsDone()) {
+ Standard_ConstructionError::Raise
+ ("Projection aborted : BRepOffsetAPI_NormalProjection failed");
+ }
+
+ aShape = OrtProj.Shape();
+ }
+
+ if (aShape.IsNull()) return 0;
+ aFunction->SetValue(aShape);
+ log.SetTouched(Label());
+ return 1;
+ }
+
// Bug 12158: Check for standalone (not included in faces) degenerated edges
TopTools_IndexedDataMapOfShapeListOfShape aEFMap;
TopExp::MapShapesAndAncestors(anOriginal, TopAbs_EDGE, TopAbs_FACE, aEFMap);
const gp_Dir dir = pos.Direction(); /* Main direction of the plane (Z axis) */
gp_Ax2 aPln (loc, dir);
aTrsf.SetMirror(aPln);
-
- } else if (aType == MIRROR_AXIS || aType == MIRROR_AXIS_COPY) {
+ }
+ else if (aType == MIRROR_AXIS || aType == MIRROR_AXIS_COPY) {
Handle(GEOM_Function) anAxis = TI.GetAxis();
if (anAxis.IsNull()) return 0;
TopoDS_Shape anAxisShape = anAxis->GetValue();
gp_Vec aV (aP1, aP2);
gp_Ax1 anAx1 (aP1, aV);
aTrsf.SetMirror(anAx1);
-
- } else if (aType == MIRROR_POINT || aType == MIRROR_POINT_COPY) {
+ }
+ else if (aType == MIRROR_POINT || aType == MIRROR_POINT_COPY) {
Handle(GEOM_Function) aPoint = TI.GetPoint();
if (aPoint.IsNull()) return 0;
TopoDS_Shape aVertexShape = aPoint->GetValue();
gp_Pnt aP = BRep_Tool::Pnt(aVertex);
aTrsf.SetMirror(aP);
- } else {
+ }
+ else {
return 0;
}
}
}
- return _anOtherObject ;
+ return _anOtherObject;
}
-
-
#define GEOM_3DSKETCHER 44
+#define GEOM_PROJECTION 45
+
//GEOM_Function types
#define COPY_WITH_REF 1
#define OFFSET_SHAPE 1
#define OFFSET_SHAPE_COPY 2
+#define PROJECTION_COPY 1
+
#define SCALE_SHAPE 1
#define SCALE_SHAPE_COPY 2
#define SCALE_SHAPE_AXES 3
if (CORBA::is_nil(theMainShape) || theIndices.length() < 1)
return GEOM::GEOM_Object::_nil();
CORBA::String_var entry = theMainShape->GetEntry();
- Handle(GEOM_Object) aMainsShape = _impl->GetObject(theMainShape->GetStudyID(), entry);
- if (aMainsShape.IsNull()) return GEOM::GEOM_Object::_nil();
+ Handle(GEOM_Object) aMainShape = _impl->GetObject(theMainShape->GetStudyID(), entry);
+ if (aMainShape.IsNull()) return GEOM::GEOM_Object::_nil();
Handle(TColStd_HArray1OfInteger) anArray = new TColStd_HArray1OfInteger(1, theIndices.length());
for(Standard_Integer i = 0; i<theIndices.length(); i++) anArray->SetValue(i+1, theIndices[i]);
- Handle(GEOM_Object) anObject = _impl->AddSubShape(aMainsShape, anArray, true);
+ Handle(GEOM_Object) anObject = _impl->AddSubShape(aMainShape, anArray, true);
if(anObject.IsNull()) return GEOM::GEOM_Object::_nil();
TCollection_AsciiString anEntry;
*/
//=============================================================================
GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeEdgeOnCurveByLength
- (GEOM::GEOM_Object_ptr theCurve,
- CORBA::Double theLength,
- GEOM::GEOM_Object_ptr theStartPoint)
+ (GEOM::GEOM_Object_ptr theCurve,
+ CORBA::Double theLength,
+ GEOM::GEOM_Object_ptr theStartPoint)
{
GEOM::GEOM_Object_var aGEOMObject;
//=============================================================================
GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeEdgeWire
(GEOM::GEOM_Object_ptr theWire,
- const CORBA::Double theLinearTolerance,
- const CORBA::Double theAngularTolerance)
+ const CORBA::Double theLinearTolerance,
+ const CORBA::Double theAngularTolerance)
{
GEOM::GEOM_Object_var aGEOMObject;
return GetObject(anObject);
}
+//=============================================================================
+/*!
+ * MakeSubShapes
+ */
+//=============================================================================
+GEOM::ListOfGO* GEOM_IShapesOperations_i::MakeSubShapes (GEOM::GEOM_Object_ptr theMainShape,
+ const GEOM::ListOfLong& theIndices)
+{
+ GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
+ Standard_Integer i;
+
+ //Set a not done flag
+ GetOperations()->SetNotDone();
+
+ if (theIndices.length() < 1)
+ return aSeq._retn();
+
+ Handle(GEOM_Object) aShape = GetObjectImpl(theMainShape);
+ if (aShape.IsNull()) return aSeq._retn();
+
+ Handle(TColStd_HArray1OfInteger) anArray = new TColStd_HArray1OfInteger (1, theIndices.length());
+ for (i = 0; i < theIndices.length(); i++)
+ anArray->SetValue(i+1, theIndices[i]);
+
+ Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->MakeSubShapes(aShape, anArray);
+ if (!GetOperations()->IsDone() || aHSeq.IsNull())
+ return aSeq._retn();
+
+ Standard_Integer aLength = aHSeq->Length();
+ aSeq->length(aLength);
+ for (i = 0; i < aLength; i++)
+ aSeq[i] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i+1)));
+
+ return aSeq._retn();
+}
+
//=============================================================================
/*!
* GetSubShapeIndex
GEOM::GEOM_Object_ptr GetSubShape (GEOM::GEOM_Object_ptr theMainShape,
CORBA::Long theID);
+ GEOM::ListOfGO* MakeSubShapes (GEOM::GEOM_Object_ptr theMainShape,
+ const GEOM::ListOfLong& theIndices);
+
CORBA::Long GetSubShapeIndex (GEOM::GEOM_Object_ptr theMainShape,
GEOM::GEOM_Object_ptr theSubShape);
return GetObject(anObject);
}
+//=============================================================================
+/*!
+ * ProjectShapeCopy
+ */
+//=============================================================================
+GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ProjectShapeCopy
+ (GEOM::GEOM_Object_ptr theSource,
+ GEOM::GEOM_Object_ptr theTarget)
+{
+ GEOM::GEOM_Object_var aGEOMObject;
+
+ //Set a not done flag
+ GetOperations()->SetNotDone();
+
+ //Get the input objects
+ Handle(GEOM_Object) aSource = GetObjectImpl(theSource);
+ Handle(GEOM_Object) aTarget = GetObjectImpl(theTarget);
+ if (aSource.IsNull() || aTarget.IsNull()) return aGEOMObject._retn();
+
+ //Create the projection
+ Handle(GEOM_Object) anObject = GetOperations()->ProjectShapeCopy(aSource, aTarget);
+ if (!GetOperations()->IsDone() || anObject.IsNull())
+ return aGEOMObject._retn();
+
+ return GetObject(anObject);
+}
+
//=============================================================================
/*!
* ScaleShape
GEOM::GEOM_Object_ptr OffsetShapeCopy (GEOM::GEOM_Object_ptr theObject,
CORBA::Double theOffset);
+ GEOM::GEOM_Object_ptr ProjectShapeCopy (GEOM::GEOM_Object_ptr theSource,
+ GEOM::GEOM_Object_ptr theTarget);
+
GEOM::GEOM_Object_ptr ScaleShape (GEOM::GEOM_Object_ptr theObject,
GEOM::GEOM_Object_ptr thePoint,
CORBA::Double theFactor);
RaiseIfFailed("ExtractSubShapes", self.ShapesOp)
return ListObj
+ ## Get a set of sub shapes defined by their unique IDs inside <VAR>theMainShape</VAR>
+ # @param theMainShape Main shape.
+ # @param theIndices List of unique IDs of sub shapes inside <VAR>theMainShape</VAR>.
+ # @return List of GEOM_Objects, corresponding to found sub shapes.
+ #
+ # @ref swig_all_decompose "Example"
+ def SubShapes(self, aShape, anIDs):
+ # Example: see GEOM_TestAll.py
+ ListObj = self.ShapesOp.MakeSubShapes(aShape, anIDs)
+ RaiseIfFailed("SubShapes", self.ShapesOp)
+ return ListObj
+
# end of l4_decompose
## @}
anObj.SetParameters(Parameters)
return anObj
+ ## Create new object as projection of the given one on a 2D surface.
+ # @param theSource The source object for the projection. It can be a point, edge or wire.
+ # @param theTarget The target object. It can be planar or cylindrical face.
+ # @return New GEOM_Object, containing the projection.
+ #
+ # @ref tui_projection "Example"
+ def MakeProjection(self, theSource, theTarget):
+ # Example: see GEOM_TestAll.py
+ anObj = self.TrsfOp.ProjectShapeCopy(theSource, theTarget)
+ RaiseIfFailed("ProjectShapeCopy", self.TrsfOp)
+ return anObj
+
# -----------------------------------------------------------------------------
# Patterns
# -----------------------------------------------------------------------------
# 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 TRANSFORMATIONGUI :
# File : Makefile.am
# Author : Alexander BORODIN, Open CASCADE S.A.S. (alexander.borodin@opencascade.com)
# Package : TransformationGUI
-#
+
include $(top_srcdir)/adm_local/unix/make_common_starter.am
# header files
TransformationGUI_MirrorDlg.h \
TransformationGUI_ScaleDlg.h \
TransformationGUI_OffsetDlg.h \
+ TransformationGUI_ProjectionDlg.h \
TransformationGUI_PositionDlg.h
# Libraries targets
TransformationGUI_MirrorDlg.h \
TransformationGUI_ScaleDlg.h \
TransformationGUI_OffsetDlg.h \
+ TransformationGUI_ProjectionDlg.h \
TransformationGUI_PositionDlg.h \
\
TransformationGUI.cxx \
TransformationGUI_MirrorDlg.cxx \
TransformationGUI_ScaleDlg.cxx \
TransformationGUI_OffsetDlg.cxx \
+ TransformationGUI_ProjectionDlg.cxx \
TransformationGUI_PositionDlg.cxx
MOC_FILES = \
TransformationGUI_MirrorDlg_moc.cxx \
TransformationGUI_ScaleDlg_moc.cxx \
TransformationGUI_OffsetDlg_moc.cxx \
+ TransformationGUI_ProjectionDlg_moc.cxx \
TransformationGUI_PositionDlg_moc.cxx
nodist_libTransformationGUI_la_SOURCES = \
../GEOMFiltersSelection/libGEOMFiltersSelection.la \
../GEOMBase/libGEOMBase.la \
$(CAS_LDPATH) -lTKShHealing
-
// 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.cxx
// Author : Damien COQUERET, Open CASCADE S.A.S.
-//
+
#include "TransformationGUI.h"
#include <GEOMBase.h>
#include "TransformationGUI_MirrorDlg.h" // Method MIRROR
#include "TransformationGUI_ScaleDlg.h" // Method SCALE
#include "TransformationGUI_OffsetDlg.h" // Method OFFSET
+#include "TransformationGUI_ProjectionDlg.h" // Method PROJECTION
#include "TransformationGUI_PositionDlg.h" // Method POSITION
//=======================================================================
case GEOMOp::OpOffset: // OFFSET
aDlg = new TransformationGUI_OffsetDlg( getGeometryGUI(), parent );
break;
+ case GEOMOp::OpProjection: // PROJECTION
+ aDlg = new TransformationGUI_ProjectionDlg( getGeometryGUI(), parent );
+ break;
case GEOMOp::OpMultiTranslate: // MULTI TRANSLATION
aDlg = new TransformationGUI_MultiTranslationDlg( getGeometryGUI(), parent );
break;
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+
+// File : TransformationGUI_ProjectionDlg.cxx
+// Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
+
+#include "TransformationGUI.h"
+#include "TransformationGUI_ProjectionDlg.h"
+
+#include <DlgRef.h>
+#include <GeometryGUI.h>
+#include <GEOMBase.h>
+
+#include <SUIT_Session.h>
+#include <SUIT_ResourceMgr.h>
+#include <SalomeApp_Application.h>
+#include <LightApp_SelectionMgr.h>
+
+//=================================================================================
+// class : TransformationGUI_ProjectionDlg()
+// purpose : Constructs a TransformationGUI_ProjectionDlg 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_ProjectionDlg::TransformationGUI_ProjectionDlg (GeometryGUI* theGeometryGUI,
+ QWidget* parent, bool modal, Qt::WindowFlags fl)
+ : GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl)
+{
+ QPixmap image0 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_PROJECTION")));
+ QPixmap image1 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT")));
+
+ setWindowTitle(tr("GEOM_PROJECTION_TITLE"));
+
+ mainFrame()->GroupConstructors->setTitle(tr("GEOM_PROJECTION"));
+ mainFrame()->RadioButton1->setIcon(image0);
+ mainFrame()->RadioButton2->setAttribute(Qt::WA_DeleteOnClose);
+ mainFrame()->RadioButton2->close();
+ mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
+ mainFrame()->RadioButton3->close();
+
+ myGroup = new DlgRef_2Sel (centralWidget());
+
+ myGroup->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
+ myGroup->TextLabel1->setText(tr("GEOM_SOURCE_OBJECT"));
+ myGroup->TextLabel2->setText(tr("GEOM_TARGET_OBJECT"));
+ 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("projection_operation_page.html");
+
+ // Initialisation
+ Init();
+}
+
+//=================================================================================
+// function : ~TransformationGUI_ProjectionDlg()
+// purpose : Destroys the object and frees any allocated resources
+//=================================================================================
+TransformationGUI_ProjectionDlg::~TransformationGUI_ProjectionDlg()
+{
+}
+
+//=================================================================================
+// function : Init()
+// purpose :
+//=================================================================================
+void TransformationGUI_ProjectionDlg::Init()
+{
+ mainFrame()->GroupBoxPublish->show();
+
+ // init variables
+ myEditCurrentArgument = myGroup->LineEdit1;
+
+ myGroup->LineEdit1->setText("");
+ myGroup->LineEdit2->setText("");
+ myObject1.nullify();
+ myObject2.nullify();
+
+ showOnlyPreviewControl();
+
+ // 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(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
+ SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
+
+ initName(mainFrame()->GroupConstructors->title());
+
+ setTabOrder(mainFrame()->GroupConstructors, mainFrame()->GroupBoxName);
+ setTabOrder(mainFrame()->GroupBoxName, mainFrame()->GroupMedium);
+ setTabOrder(mainFrame()->GroupMedium, mainFrame()->GroupButtons);
+
+ mainFrame()->RadioButton1->setFocus();
+
+ globalSelection(GEOM_ALLSHAPES);
+
+ myGroup->PushButton1->click();
+ SelectionIntoArgument();
+ resize(100,100);
+}
+
+//=================================================================================
+// function : ClickOnOk()
+// purpose :
+//=================================================================================
+void TransformationGUI_ProjectionDlg::ClickOnOk()
+{
+ setIsApplyAndClose(true);
+ if (ClickOnApply())
+ ClickOnCancel();
+}
+
+//=================================================================================
+// function : ClickOnApply()
+// purpose :
+//=================================================================================
+bool TransformationGUI_ProjectionDlg::ClickOnApply()
+{
+ if (!onAccept())
+ return false;
+
+ initName();
+ // activate selection and connect selection manager
+ myGroup->PushButton1->click();
+ return true;
+}
+
+//=================================================================================
+// function : SelectionIntoArgument()
+// purpose : Called when selection is changed or on dialog initialization or activation
+//=================================================================================
+void TransformationGUI_ProjectionDlg::SelectionIntoArgument()
+{
+ myEditCurrentArgument->setText("");
+
+ GEOM::GeomObjPtr aSelectedObject = getSelected(TopAbs_SHAPE);
+ TopoDS_Shape aShape;
+ if (aSelectedObject && GEOMBase::GetShape(aSelectedObject.get(), aShape) && !aShape.IsNull()) {
+ QString aName = GEOMBase::GetName(aSelectedObject.get());
+ myEditCurrentArgument->setText(aName);
+
+ // clear selection
+ disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
+ myGeomGUI->getApp()->selectionMgr()->clearSelected();
+ connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
+ this, SLOT(SelectionIntoArgument()));
+
+ if (myEditCurrentArgument == myGroup->LineEdit1) {
+ myObject1 = aSelectedObject;
+ if (!myObject2)
+ myGroup->PushButton2->click();
+ }
+ else if (myEditCurrentArgument == myGroup->LineEdit2) {
+ myObject2 = aSelectedObject;
+ if (!myObject1)
+ myGroup->PushButton1->click();
+ }
+ }
+ else {
+ if (myEditCurrentArgument == myGroup->LineEdit1) myObject1.nullify();
+ else if (myEditCurrentArgument == myGroup->LineEdit2) myObject2.nullify();
+ }
+}
+
+//=================================================================================
+// function : SetEditCurrentArgument()
+// purpose :
+//=================================================================================
+void TransformationGUI_ProjectionDlg::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 : ActivateThisDialog()
+// purpose :
+//=================================================================================
+void TransformationGUI_ProjectionDlg::ActivateThisDialog()
+{
+ GEOMBase_Skeleton::ActivateThisDialog();
+
+ connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
+ this, SLOT(SelectionIntoArgument()));
+ processPreview();
+}
+
+//=================================================================================
+// function : enterEvent()
+// purpose : when mouse enter onto the QWidget
+//=================================================================================
+void TransformationGUI_ProjectionDlg::enterEvent (QEvent*)
+{
+ if (!mainFrame()->GroupConstructors->isEnabled())
+ ActivateThisDialog();
+}
+
+//=================================================================================
+// function : createOperation
+// purpose :
+//=================================================================================
+GEOM::GEOM_IOperations_ptr TransformationGUI_ProjectionDlg::createOperation()
+{
+ return getGeomEngine()->GetITransformOperations(getStudyId());
+}
+
+//=================================================================================
+// function : isValid
+// purpose :
+//=================================================================================
+bool TransformationGUI_ProjectionDlg::isValid (QString&)
+{
+ return myObject1 && myObject2;
+}
+
+//=================================================================================
+// function : execute
+// purpose :
+//=================================================================================
+bool TransformationGUI_ProjectionDlg::execute (ObjectList& objects)
+{
+ GEOM::GEOM_Object_var anObj;
+
+ GEOM::GEOM_ITransformOperations_var anOper = GEOM::GEOM_ITransformOperations::_narrow(getOperation());
+ anObj = anOper->ProjectShapeCopy(myObject1.get(), myObject2.get());
+ if (!anObj->_is_nil())
+ objects.push_back(anObj._retn());
+
+ return true;
+}
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+
+// File : TransformationGUI_ProjectionDlg.h
+// Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
+
+#ifndef TRANSFORMATIONGUI_PROJECTIONDLG_H
+#define TRANSFORMATIONGUI_PROJECTIONDLG_H
+
+#include "GEOMBase_Skeleton.h"
+#include "GEOM_GenericObjPtr.h"
+
+class DlgRef_2Sel;
+
+//=================================================================================
+// class : TransformationGUI_ProjectionDlg
+// purpose :
+//=================================================================================
+class TransformationGUI_ProjectionDlg : public GEOMBase_Skeleton
+{
+ Q_OBJECT
+
+public:
+ TransformationGUI_ProjectionDlg (GeometryGUI*, QWidget* = 0,
+ bool = false, Qt::WindowFlags = 0 );
+ ~TransformationGUI_ProjectionDlg();
+
+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;
+
+ DlgRef_2Sel* myGroup;
+
+private slots:
+ void ClickOnOk();
+ bool ClickOnApply();
+ void SetEditCurrentArgument();
+ void SelectionIntoArgument();
+ void ActivateThisDialog();
+};
+
+#endif // TRANSFORMATIONGUI_PROJECTIONDLG_H