mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-01-31 00:10:34 +05:00
DCQ : new sketcher
This commit is contained in:
parent
6e38bb5a4d
commit
d973076d2f
58
src/GEOM_SWIG/GEOM_Sketcher.py
Normal file
58
src/GEOM_SWIG/GEOM_Sketcher.py
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
# GEOM GEOM_SWIG : binding of C++ omplementaion with Python
|
||||||
|
#
|
||||||
|
# Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# File : GEOM_Sketcher.py
|
||||||
|
# Author : Damien COQUERET, Open CASCADE
|
||||||
|
# Module : GEOM
|
||||||
|
# $Header$
|
||||||
|
|
||||||
|
import geompy
|
||||||
|
|
||||||
|
#SKETCHER INFOS
|
||||||
|
#Init Sketcher
|
||||||
|
#Create a string beginning by :"Sketcher:"
|
||||||
|
#Each command must be separated by ":"
|
||||||
|
#"F x y" : Create first point at X & Y
|
||||||
|
|
||||||
|
#To Make Segment
|
||||||
|
#"R angle" : Set the direction by angle
|
||||||
|
#"D dx dy" : Set the direction by DX & DY
|
||||||
|
|
||||||
|
#"TT x y" : Create by point at X & Y
|
||||||
|
#"T dx dy" : Create by point with DX & DY
|
||||||
|
#"L length" : Create by direction & Length
|
||||||
|
#"IX x" : Create by direction & Intersect. X
|
||||||
|
#"IY y" : Create by direction & Intersect. Y
|
||||||
|
|
||||||
|
#To Make Arc
|
||||||
|
#"C radius length" : Create by direction, radius and length(in degree)
|
||||||
|
|
||||||
|
#To finish
|
||||||
|
#"WW" : Close Wire
|
||||||
|
|
||||||
|
#Create Sketcher
|
||||||
|
Cmd = "Sketch:F 0 0:TT 0 100:C 100 180:WW"
|
||||||
|
Sketcher = geompy.MakeSketcher(Cmd) #(string)->GEOM_Shape_ptr
|
||||||
|
|
||||||
|
#Add In Study
|
||||||
|
id_Sketcher = geompy.addToStudy(Sketcher, "Sketcher")
|
@ -51,7 +51,8 @@ EXPORT_PYSCRIPTS = libGEOM_Swig.py geompy.py batchmode_geompy.py \
|
|||||||
GEOM_Partition2.py \
|
GEOM_Partition2.py \
|
||||||
GEOM_Partition3.py \
|
GEOM_Partition3.py \
|
||||||
GEOM_Partition4.py \
|
GEOM_Partition4.py \
|
||||||
GEOM_Partition5.py
|
GEOM_Partition5.py \
|
||||||
|
GEOM_Sketcher.py
|
||||||
|
|
||||||
LIB_CLIENT_IDL = SALOMEDS.idl \
|
LIB_CLIENT_IDL = SALOMEDS.idl \
|
||||||
SALOMEDS_Attributes.idl \
|
SALOMEDS_Attributes.idl \
|
||||||
|
@ -164,6 +164,12 @@ def MakePlane(p1,d1,trimsize):
|
|||||||
anObj._set_Name(ior)
|
anObj._set_Name(ior)
|
||||||
return anObj
|
return anObj
|
||||||
|
|
||||||
|
def MakeSketcher(Cmd):
|
||||||
|
anObj = geom.MakeSketcher(Cmd)
|
||||||
|
ior = orb.object_to_string(anObj)
|
||||||
|
anObj._set_Name(ior)
|
||||||
|
return anObj
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# Create Geometry 3D
|
# Create Geometry 3D
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
@ -190,6 +190,12 @@ def MakePlane(p1,d1,trimsize):
|
|||||||
anObj._set_Name(ior)
|
anObj._set_Name(ior)
|
||||||
return anObj
|
return anObj
|
||||||
|
|
||||||
|
def MakeSketcher(Cmd):
|
||||||
|
anObj = geom.MakeSketcher(Cmd)
|
||||||
|
ior = salome.orb.object_to_string(anObj)
|
||||||
|
anObj._set_Name(ior)
|
||||||
|
return anObj
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# Create Geometry 3D
|
# Create Geometry 3D
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,201 +0,0 @@
|
|||||||
// GEOM SKETCHER : basic sketcher
|
|
||||||
//
|
|
||||||
// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// File : GEOM_Sketcher.h
|
|
||||||
// Author : Nicolas REJNERI
|
|
||||||
// Module : GEOM
|
|
||||||
// $Header$
|
|
||||||
|
|
||||||
#include "GEOM_SketcherStatus.h"
|
|
||||||
|
|
||||||
#include <V3d_Viewer.hxx>
|
|
||||||
#include <V3d_View.hxx>
|
|
||||||
#include <BRepBuilderAPI_MakeWire.hxx>
|
|
||||||
#include <Geom_Plane.hxx>
|
|
||||||
#include <AIS_InteractiveContext.hxx>
|
|
||||||
#include <AIS_Shape.hxx>
|
|
||||||
#include <AIS_Axis.hxx>
|
|
||||||
#include <TopoDS_Edge.hxx>
|
|
||||||
#include <AIS_LengthDimension.hxx>
|
|
||||||
#include <AIS_RadiusDimension.hxx>
|
|
||||||
#include <AIS_AngleDimension.hxx>
|
|
||||||
#include <Geom2d_Line.hxx>
|
|
||||||
#include <TColStd_SequenceOfInteger.hxx>
|
|
||||||
#include <TColgp_SequenceOfPnt2d.hxx>
|
|
||||||
#include <gp_Vec2d.hxx>
|
|
||||||
|
|
||||||
class Sketch
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Sketch();
|
|
||||||
~Sketch();
|
|
||||||
Sketch(const Handle(V3d_Viewer)& aViewer);
|
|
||||||
Sketch(const Handle(V3d_Viewer)& aViewer,
|
|
||||||
const Quantity_Color& anAxisColor,
|
|
||||||
const Quantity_Color& aCurrentColor,
|
|
||||||
const Quantity_Color& aWireColor);
|
|
||||||
|
|
||||||
static void fitInResol(Standard_Real &toFit,
|
|
||||||
Standard_Boolean minIsResol = Standard_False);
|
|
||||||
|
|
||||||
void MakeCurrentEdge(const Standard_Integer Xp ,
|
|
||||||
const Standard_Integer Yp ,
|
|
||||||
const Handle(V3d_View)& aView );
|
|
||||||
|
|
||||||
void MakeCurrentEdge(const Standard_Real X, const Standard_Real Y);
|
|
||||||
|
|
||||||
Standard_Boolean SetDimension(Standard_Real& aValue);
|
|
||||||
void SetDimension(Standard_Real& deltaX,Standard_Real& deltaY);
|
|
||||||
|
|
||||||
void SetXDimension(Standard_Real& deltaX);
|
|
||||||
void SetYDimension(Standard_Real& deltaY);
|
|
||||||
|
|
||||||
void SetSegmentAngle(Standard_Real& aValue);
|
|
||||||
Standard_Real GetSegmentAngle();
|
|
||||||
|
|
||||||
void ValidateEdge();
|
|
||||||
|
|
||||||
TopoDS_Wire Close();
|
|
||||||
TopoDS_Wire End();
|
|
||||||
|
|
||||||
void Clear();
|
|
||||||
|
|
||||||
Standard_Boolean Delete();
|
|
||||||
|
|
||||||
void SetPlane(const Handle(Geom_Plane)& aPlane);
|
|
||||||
|
|
||||||
void SetWireColor(const Quantity_Color& aColor);
|
|
||||||
void SetCurrentColor(const Quantity_Color& aColor);
|
|
||||||
void SetAxisColor(const Quantity_Color& aColor);
|
|
||||||
|
|
||||||
void SetParameterVisibility(const TypeOfParameter atype,
|
|
||||||
const Standard_Boolean OnOff);
|
|
||||||
|
|
||||||
void HiligthWithColor(const TypeOfParameter atype,
|
|
||||||
const Quantity_NameOfColor acolor);
|
|
||||||
void Unhiligth(const TypeOfParameter atype);
|
|
||||||
|
|
||||||
Standard_Boolean IsValidCurrentParameter(const TypeOfParameter atype);
|
|
||||||
|
|
||||||
void SetParameterValue(const TypeOfParameter atype, Standard_Real aValue);
|
|
||||||
|
|
||||||
void ChangeMode(const SketchStatus aMode);
|
|
||||||
|
|
||||||
void SetTransitionStatus(const TransitionStatus aStatus);
|
|
||||||
|
|
||||||
SketchStatus GetCurrentStatus();
|
|
||||||
Standard_Integer GetmyEdgesNumber();
|
|
||||||
|
|
||||||
private :
|
|
||||||
|
|
||||||
void Init();
|
|
||||||
|
|
||||||
void MakeCurrentSegment(Standard_Real X, Standard_Real Y);
|
|
||||||
|
|
||||||
void MakeCurrentArc(Standard_Real X, Standard_Real Y);
|
|
||||||
|
|
||||||
void DisplayCurrentEdge();
|
|
||||||
|
|
||||||
void DisplayLengthDimension(const TopoDS_Vertex& V1,const TopoDS_Vertex& V2);
|
|
||||||
void DisplayXDimension(const TopoDS_Vertex& V1,const TopoDS_Vertex& V2);
|
|
||||||
void DisplayYDimension(const TopoDS_Vertex& V1,const TopoDS_Vertex& V2);
|
|
||||||
void DisplayAngleDimension();
|
|
||||||
void DisplayRadiusDimension();
|
|
||||||
|
|
||||||
void AddEdgeToWire();
|
|
||||||
|
|
||||||
void RemoveLastEdge();
|
|
||||||
|
|
||||||
void CreateConstraints();
|
|
||||||
|
|
||||||
private:
|
|
||||||
// Current status of construction
|
|
||||||
SketchStatus myCurrentStatus;
|
|
||||||
// Transition status between arcs and segments
|
|
||||||
TransitionStatus myTransitionStatus;
|
|
||||||
// Current wire
|
|
||||||
BRepBuilderAPI_MakeWire myCurrentWire;
|
|
||||||
// Current presentable wire
|
|
||||||
Handle_AIS_Shape myPresentableWire;
|
|
||||||
// Number of edges into the current wire
|
|
||||||
Standard_Integer myEdgesNumber;
|
|
||||||
// Store for each edge how it has been built i.d the value of myCurrentStatus
|
|
||||||
TColStd_SequenceOfInteger myConstructionMode;
|
|
||||||
// Store for each edge how it has been built i.d the value of myTransitionStatus
|
|
||||||
TColStd_SequenceOfInteger myConstraintMode;
|
|
||||||
// Current edge
|
|
||||||
TopoDS_Shape myCurrentEdge;
|
|
||||||
// Previous edge
|
|
||||||
TopoDS_Edge myPreviousEdge;
|
|
||||||
// List of points to interpolate when computing a curve by interpolation
|
|
||||||
TColgp_SequenceOfPnt2d myPointsToInterpolate;
|
|
||||||
// Tangent vector at beginning of curve
|
|
||||||
gp_Vec2d myTangentVector;
|
|
||||||
// Tangent flag at beginning og curve
|
|
||||||
Standard_Boolean myTangentFlag;
|
|
||||||
|
|
||||||
// Origin of sketch
|
|
||||||
TopoDS_Vertex myFirstPointSketch;
|
|
||||||
// Last x coordinate of end point of previous edge or picked point
|
|
||||||
Standard_Real myLastX;
|
|
||||||
// Last y coordinate of end point of previous edge or picked point
|
|
||||||
Standard_Real myLastY;
|
|
||||||
// angle between 2 segments when an ANGLE TransitionStatus is set.
|
|
||||||
Standard_Real mySegmentAngle;
|
|
||||||
// Length of segment when the length of the segment is fixed before the angle
|
|
||||||
Standard_Real mySegmentLength;
|
|
||||||
// Value of X fixed coordinate
|
|
||||||
Standard_Real mySegmentX;
|
|
||||||
// Value of Y fixed Coordinate
|
|
||||||
Standard_Real mySegmentY;
|
|
||||||
Handle_AIS_Shape myPresentableEdge; // Current presentable edge
|
|
||||||
Handle_AIS_LengthDimension myLengthDimension;// For display of current length segment dimension
|
|
||||||
Handle_AIS_LengthDimension myXDimension; // For display of current X segment dimension
|
|
||||||
Handle_AIS_LengthDimension myYDimension; // For display of current Y segment dimension
|
|
||||||
Handle_AIS_LengthDimension myRadiusDimension;// For display of current radius dimension
|
|
||||||
Handle_AIS_AngleDimension myAngleDimension; // For display of current angle dimension
|
|
||||||
Standard_Boolean myIsLengthDimensionVisible; // Visibility flag for LengthDimension
|
|
||||||
Standard_Boolean myIsXDimensionVisible; // Visibility flag for X Dimension
|
|
||||||
Standard_Boolean myIsYDimensionVisible; // Visibility flag for Y Dimension
|
|
||||||
Standard_Boolean myIsRadiusDimensionVisible; // Visibility flag for RadiusDimension
|
|
||||||
Standard_Boolean myIsAngleDimensionVisible; // Visibility flag for AngleDimension
|
|
||||||
Handle_AIS_Axis myPresentableMediatrice; // Chord mediatrice of current circle as a presentable object
|
|
||||||
Handle_Geom2d_Line myMediatrice; // Chord mediatrice of current circle as a 2d line
|
|
||||||
Handle_AIS_Shape myCenterCircle; // to visualise center of current arc
|
|
||||||
|
|
||||||
Handle_AIS_Axis myHAxis; // Horizontal axis
|
|
||||||
Handle_AIS_Axis myVAxis; // Vertical axis
|
|
||||||
Handle_AIS_Axis myAngularAxis; // Axis making a predefined angle with the previous edge
|
|
||||||
|
|
||||||
Quantity_Color myWireColor; // Color of wire and of build edges
|
|
||||||
Quantity_Color myCurrentColor; // Color of edge under construction
|
|
||||||
Quantity_Color myAxisColor; // Color for axis
|
|
||||||
Handle_AIS_InteractiveContext myInteractiveContext; // Interactive context for display management
|
|
||||||
|
|
||||||
Handle_Geom_Plane myPlane; // Plane of sketch
|
|
||||||
|
|
||||||
BRepBuilderAPI_MakeWire myPasteWire;
|
|
||||||
Standard_Integer myPasteEdgesNumber;
|
|
||||||
TColStd_SequenceOfInteger myPasteConstructionMode;
|
|
||||||
TColStd_SequenceOfInteger myPasteConstraintMode;
|
|
||||||
};
|
|
@ -36,22 +36,16 @@ VPATH=.:@srcdir@:@top_srcdir@/idl
|
|||||||
|
|
||||||
# Libraries targets
|
# Libraries targets
|
||||||
LIB = libGEOMSketcher.la
|
LIB = libGEOMSketcher.la
|
||||||
LIB_SRC = GEOM_Sketcher.cxx
|
LIB_SRC = Sketcher_Profile.cxx
|
||||||
LIB_CLIENT_IDL = SALOME_Component.idl SALOMEDS.idl SALOME_Exception.idl GEOM_Shape.idl GEOM_Gen.idl
|
LIB_CLIENT_IDL = SALOME_Component.idl SALOMEDS.idl SALOME_Exception.idl
|
||||||
|
|
||||||
# header files
|
# header files
|
||||||
EXPORT_HEADERS= GEOM_Sketcher.h \
|
EXPORT_HEADERS= Sketcher_Profile.hxx
|
||||||
GEOM_SketcherStatus.h
|
|
||||||
|
|
||||||
# additionnal information to compil and link file
|
# additionnal information to compil and link file
|
||||||
CPPFLAGS += $(OCC_INCLUDES) $(QT_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome
|
CPPFLAGS += $(OCC_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome
|
||||||
CXXFLAGS += $(OCC_CXXFLAGS) -I${KERNEL_ROOT_DIR}/include/salome
|
CXXFLAGS += -I${KERNEL_ROOT_DIR}/include/salome
|
||||||
LDFLAGS += $(QT_LIBS) $(CAS_LDPATH) -lTKTopAlgo -L${KERNEL_ROOT_DIR}/lib/salome
|
LDFLAGS += $(OCC_KERNEL_LIBS) $(OCC_MODELER_LIBS) -L${KERNEL_ROOT_DIR}/lib/salome
|
||||||
|
|
||||||
# additional file to be cleaned
|
|
||||||
MOSTLYCLEAN =
|
|
||||||
CLEAN =
|
|
||||||
DISTCLEAN =
|
|
||||||
|
|
||||||
@CONCLUDE@
|
@CONCLUDE@
|
||||||
|
|
||||||
|
382
src/SKETCHER/Sketcher_Profile.cxx
Normal file
382
src/SKETCHER/Sketcher_Profile.cxx
Normal file
@ -0,0 +1,382 @@
|
|||||||
|
// GEOM SKETCHER : basic sketcher
|
||||||
|
//
|
||||||
|
// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// File : Sketcher_Profile.cxx
|
||||||
|
// Author : Damien COQUERET
|
||||||
|
// Module : GEOM
|
||||||
|
// $Header:
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
#include "Sketcher_Profile.hxx"
|
||||||
|
|
||||||
|
#include <TopoDS_Vertex.hxx>
|
||||||
|
#include <TopoDS_Face.hxx>
|
||||||
|
#include <gp_Pln.hxx>
|
||||||
|
#include <gp_Ax2.hxx>
|
||||||
|
#include <BRepLib.hxx>
|
||||||
|
#include <BRepBuilderAPI_MakeVertex.hxx>
|
||||||
|
#include <BRepBuilderAPI_MakeEdge.hxx>
|
||||||
|
#include <BRepBuilderAPI_MakeWire.hxx>
|
||||||
|
#include <BRepBuilderAPI_MakeFace.hxx>
|
||||||
|
#include <Geom2d_Line.hxx>
|
||||||
|
#include <Geom2d_Circle.hxx>
|
||||||
|
#include <Geom_Surface.hxx>
|
||||||
|
#include <Precision.hxx>
|
||||||
|
#include <GeomAPI.hxx>
|
||||||
|
|
||||||
|
#include <TCollection_AsciiString.hxx>
|
||||||
|
|
||||||
|
#include <SALOMEconfig.h>
|
||||||
|
#include CORBA_SERVER_HEADER(SALOMEDS)
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
// profile
|
||||||
|
// command to build a profile
|
||||||
|
//=======================================================================
|
||||||
|
Sketcher_Profile::Sketcher_Profile()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
// profile
|
||||||
|
// command to build a profile
|
||||||
|
//=======================================================================
|
||||||
|
Sketcher_Profile::Sketcher_Profile(const char* aCmd)
|
||||||
|
{
|
||||||
|
enum {line, circle, point, none} move;
|
||||||
|
|
||||||
|
Standard_Integer i = 1;
|
||||||
|
Standard_Real x0, y0, x, y, dx, dy;
|
||||||
|
x0 = y0 = x = y = dy = 0;
|
||||||
|
dx = 1;
|
||||||
|
|
||||||
|
Standard_Boolean first, stayfirst, face, close;
|
||||||
|
first = Standard_True;
|
||||||
|
stayfirst = face = close = Standard_False;
|
||||||
|
|
||||||
|
TopoDS_Shape S;
|
||||||
|
TopoDS_Vertex MP;
|
||||||
|
BRepBuilderAPI_MakeWire MW;
|
||||||
|
gp_Ax3 DummyHP(gp::XOY());
|
||||||
|
gp_Pln P(DummyHP);
|
||||||
|
TopLoc_Location TheLocation;
|
||||||
|
Handle(Geom_Surface) Surface;
|
||||||
|
|
||||||
|
myOK = Standard_False;
|
||||||
|
|
||||||
|
TCollection_AsciiString aCommand(CORBA::string_dup(aCmd));
|
||||||
|
TCollection_AsciiString aToken = aCommand.Token(":", 1);
|
||||||
|
int n = 0;
|
||||||
|
TCollection_AsciiString aTab[aCommand.Length()];
|
||||||
|
while(aToken.Length() != 0) {
|
||||||
|
if(aCommand.Token(":", n + 1).Length() > 0)
|
||||||
|
aTab[n] = aCommand.Token(":", n + 1);
|
||||||
|
aToken = aCommand.Token(":", ++n);
|
||||||
|
}
|
||||||
|
n = n - 1;
|
||||||
|
|
||||||
|
while(i < n) {
|
||||||
|
Standard_Real length = 0, radius = 0, angle = 0;
|
||||||
|
move = point;
|
||||||
|
|
||||||
|
int n1 = 0;
|
||||||
|
TCollection_AsciiString a[aTab[0].Length()];
|
||||||
|
aToken = aTab[i].Token(" ", 1);
|
||||||
|
while(aToken.Length() != 0) {
|
||||||
|
if(aTab[i].Token(" ", n1 + 1).Length() > 0)
|
||||||
|
a[n1] = aTab[i].Token(" ", n1 + 1);
|
||||||
|
aToken = aTab[i].Token(" ", ++n1);
|
||||||
|
}
|
||||||
|
n1 = n1 - 1;
|
||||||
|
|
||||||
|
switch(a[0].Value(1))
|
||||||
|
{
|
||||||
|
case 'F':
|
||||||
|
{
|
||||||
|
if (n1 != 3) goto badargs;
|
||||||
|
if (!first) {
|
||||||
|
cout<<"profile : The F instruction must precede all moves"<<endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
x0 = x = a[1].RealValue();
|
||||||
|
y0 = y = a[2].RealValue();
|
||||||
|
stayfirst = Standard_True;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'O':
|
||||||
|
{
|
||||||
|
if (n1 != 4) goto badargs;
|
||||||
|
P.SetLocation(gp_Pnt(a[1].RealValue(), a[2].RealValue(), a[3].RealValue()));
|
||||||
|
stayfirst = Standard_True;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'P':
|
||||||
|
{
|
||||||
|
if (n1 != 7) goto badargs;
|
||||||
|
gp_Vec vn(a[1].RealValue(), a[2].RealValue(), a[3].RealValue());
|
||||||
|
gp_Vec vx(a[4].RealValue(), a[5].RealValue(), a[6].RealValue());
|
||||||
|
if (vn.Magnitude() <= Precision::Confusion() || vx.Magnitude() <= Precision::Confusion()) {
|
||||||
|
cout<<"profile : null direction"<<endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
gp_Ax2 ax(P.Location(), vn, vx);
|
||||||
|
P.SetPosition(ax);
|
||||||
|
stayfirst = Standard_True;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'X':
|
||||||
|
{
|
||||||
|
if (n1 != 2) goto badargs;
|
||||||
|
length = a[1].RealValue();
|
||||||
|
if (a[0] == "XX")
|
||||||
|
length -= x;
|
||||||
|
dx = 1; dy = 0;
|
||||||
|
move = line;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'Y':
|
||||||
|
{
|
||||||
|
if (n1 != 2) goto badargs;
|
||||||
|
length = a[1].RealValue();
|
||||||
|
if (a[0] == "YY")
|
||||||
|
length -= y;
|
||||||
|
dx = 0; dy = 1;
|
||||||
|
move = line;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'L':
|
||||||
|
{
|
||||||
|
if (n1 != 2) goto badargs;
|
||||||
|
length = a[1].RealValue();
|
||||||
|
if (Abs(length) > Precision::Confusion())
|
||||||
|
move = line;
|
||||||
|
else
|
||||||
|
move = none;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'T':
|
||||||
|
{
|
||||||
|
if (n1 != 3) goto badargs;
|
||||||
|
Standard_Real vx = a[1].RealValue();
|
||||||
|
Standard_Real vy = a[2].RealValue();
|
||||||
|
if (a[0] == "TT") {
|
||||||
|
vx -= x;
|
||||||
|
vy -= y;
|
||||||
|
}
|
||||||
|
length = Sqrt(vx * vx + vy * vy);
|
||||||
|
if (length > Precision::Confusion()) {
|
||||||
|
move = line;
|
||||||
|
dx = vx / length;
|
||||||
|
dy = vy / length;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
move = none;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'R':
|
||||||
|
{
|
||||||
|
if (n1 != 2) goto badargs;
|
||||||
|
angle = a[1].RealValue() * PI180;
|
||||||
|
if (a[0] == "RR") {
|
||||||
|
dx = Cos(angle);
|
||||||
|
dy = Sin(angle);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Standard_Real c = Cos(angle);
|
||||||
|
Standard_Real s = Sin(angle);
|
||||||
|
Standard_Real t = c * dx - s * dy;
|
||||||
|
dy = s * dx + c * dy;
|
||||||
|
dx = t;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'D':
|
||||||
|
{
|
||||||
|
if (n1 != 3) goto badargs;
|
||||||
|
Standard_Real vx = a[1].RealValue();
|
||||||
|
Standard_Real vy = a[2].RealValue();
|
||||||
|
length = Sqrt(vx * vx + vy * vy);
|
||||||
|
if (length > Precision::Confusion()) {
|
||||||
|
dx = vx / length;
|
||||||
|
dy = vy / length;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
move = none;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'C':
|
||||||
|
{
|
||||||
|
if (n1 != 3) goto badargs;
|
||||||
|
radius = a[1].RealValue();
|
||||||
|
if (Abs(radius) > Precision::Confusion()) {
|
||||||
|
angle = a[2].RealValue() * PI180;
|
||||||
|
move = circle;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
move = none;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'I':
|
||||||
|
{
|
||||||
|
if (n1 != 2) goto badargs;
|
||||||
|
length = a[1].RealValue();
|
||||||
|
if (a[0] == "IX") {
|
||||||
|
if (Abs(dx) < Precision::Confusion()) {
|
||||||
|
cout<<"profile : cannot intersect, arg "<<i-1<<endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
length = (length - x) / dx;
|
||||||
|
}
|
||||||
|
else if (a[0] == "IY") {
|
||||||
|
if (Abs(dy) < Precision::Confusion()) {
|
||||||
|
cout<<"profile : cannot intersect, arg "<<i-1<<endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
length = (length - y) / dy;
|
||||||
|
}
|
||||||
|
if (Abs(length) > Precision::Confusion())
|
||||||
|
move = line;
|
||||||
|
else
|
||||||
|
move = none;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'W':
|
||||||
|
{
|
||||||
|
if (a[0] == "WW")
|
||||||
|
close = Standard_True;
|
||||||
|
else if(a[0] == "WF") {
|
||||||
|
close = Standard_True;
|
||||||
|
face = Standard_True;
|
||||||
|
}
|
||||||
|
i = n - 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
cout<<"profile : unknown code "<<a[i]<<endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
again :
|
||||||
|
switch (move)
|
||||||
|
{
|
||||||
|
case line :
|
||||||
|
{
|
||||||
|
if (length < 0) {
|
||||||
|
length = -length;
|
||||||
|
dx = -dx;
|
||||||
|
dy = -dy;
|
||||||
|
}
|
||||||
|
Handle(Geom2d_Line) l = new Geom2d_Line(gp_Pnt2d(x,y),gp_Dir2d(dx,dy));
|
||||||
|
MW.Add(BRepBuilderAPI_MakeEdge(GeomAPI::To3d(l,P),0,length));
|
||||||
|
x += length*dx;
|
||||||
|
y += length*dy;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case circle :
|
||||||
|
{
|
||||||
|
Standard_Boolean sense = Standard_True;
|
||||||
|
if (radius < 0) {
|
||||||
|
radius = -radius;
|
||||||
|
sense = !sense;
|
||||||
|
dx = -dx;
|
||||||
|
dy = -dy;
|
||||||
|
}
|
||||||
|
gp_Ax2d ax(gp_Pnt2d(x-radius*dy,y+radius*dx),gp_Dir2d(dy,-dx));
|
||||||
|
if (angle < 0) {
|
||||||
|
angle = -angle;
|
||||||
|
sense = !sense;
|
||||||
|
}
|
||||||
|
Handle(Geom2d_Circle) c = new Geom2d_Circle(ax,radius,sense);
|
||||||
|
MW.Add(BRepBuilderAPI_MakeEdge(GeomAPI::To3d(c,P),0,angle));
|
||||||
|
gp_Pnt2d p;
|
||||||
|
gp_Vec2d v;
|
||||||
|
c->D1(angle,p,v);
|
||||||
|
x = p.X();
|
||||||
|
y = p.Y();
|
||||||
|
dx = v.X() / radius;
|
||||||
|
dy = v.Y() / radius;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case point:
|
||||||
|
{
|
||||||
|
MP = BRepBuilderAPI_MakeVertex(gp_Pnt(x, y, 0.0));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case none:
|
||||||
|
{
|
||||||
|
i = n - 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// update first
|
||||||
|
first = stayfirst;
|
||||||
|
stayfirst = Standard_False;
|
||||||
|
|
||||||
|
if(!(dx == 0 && dy == 0))
|
||||||
|
myLastDir.SetCoord(dx, dy, 0.0);
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
myLastPoint.SetX(x);
|
||||||
|
myLastPoint.SetY(y);
|
||||||
|
|
||||||
|
// next segment....
|
||||||
|
i++;
|
||||||
|
if ((i == n) && close) {
|
||||||
|
// the closing segment
|
||||||
|
dx = x0 - x;
|
||||||
|
dy = y0 - y;
|
||||||
|
length = Sqrt(dx * dx + dy * dy);
|
||||||
|
move = line;
|
||||||
|
if (length > Precision::Confusion()) {
|
||||||
|
dx = dx / length;
|
||||||
|
dy = dy / length;
|
||||||
|
goto again;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// get the result, face or wire
|
||||||
|
if (move == none)
|
||||||
|
return;
|
||||||
|
else if (move == point)
|
||||||
|
S = MP;
|
||||||
|
else if (face)
|
||||||
|
S = BRepBuilderAPI_MakeFace(P, MW.Wire());
|
||||||
|
else
|
||||||
|
S = MW;
|
||||||
|
|
||||||
|
if(!TheLocation.IsIdentity())
|
||||||
|
S.Move(TheLocation);
|
||||||
|
|
||||||
|
myShape = S;
|
||||||
|
myOK = true;
|
||||||
|
return;
|
||||||
|
|
||||||
|
badargs :
|
||||||
|
cout<<"profile : bad number of arguments"<<endl;
|
||||||
|
return;
|
||||||
|
}
|
@ -21,33 +21,34 @@
|
|||||||
//
|
//
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// File : GEOM_SketcherStatus.h
|
// File : Sketcher_Profile.h
|
||||||
// Author : Nicolas REJNERI
|
// Author : Damien COQUERET
|
||||||
// Module : GEOM
|
// Module : GEOM
|
||||||
// $Header$
|
// $Header:
|
||||||
|
|
||||||
enum TransitionStatus {
|
#include <gp_Pnt.hxx>
|
||||||
NOCONSTRAINT, // no constraint between consecutive edges
|
#include <gp_Dir.hxx>
|
||||||
TANGENT, // arc and segment are tangent
|
#include <TopoDS_Shape.hxx>
|
||||||
PERPENDICULAR,// arc is tangent to the perpendicular to the segment
|
|
||||||
ANGLE, // Angular constraint between 2 segments
|
|
||||||
LENGTH_FIXED, // Length of segment has been fixed
|
|
||||||
X_FIXED, // X coordinate for segment has been fixed
|
|
||||||
Y_FIXED // Y coordinate for segment has been fixed
|
|
||||||
};
|
|
||||||
|
|
||||||
enum TypeOfParameter {
|
class Sketcher_Profile
|
||||||
ANGLE_PARAMETER,
|
{
|
||||||
LENGTH_PARAMETER,
|
|
||||||
RADIUS_PARAMETER,
|
public:
|
||||||
XVALUE_PARAMETER,
|
Sketcher_Profile();
|
||||||
YVALUE_PARAMETER
|
Sketcher_Profile(const char* aCmd);
|
||||||
};
|
|
||||||
|
private:
|
||||||
|
gp_Pnt myLastPoint;
|
||||||
|
gp_Dir myLastDir;
|
||||||
|
|
||||||
|
TopoDS_Shape myShape;
|
||||||
|
bool myOK;
|
||||||
|
|
||||||
|
public:
|
||||||
|
gp_Pnt GetLastPoint(){return myLastPoint;};
|
||||||
|
gp_Dir GetLastDir(){return myLastDir;};
|
||||||
|
|
||||||
|
const TopoDS_Shape& GetShape(){return myShape;};
|
||||||
|
bool IsDone(){return myOK;};
|
||||||
|
|
||||||
enum SketchStatus {
|
|
||||||
BEGIN_SKETCH, // Begin sketch; no edges created yet
|
|
||||||
SEGMENT, // Current mode for creation is segment
|
|
||||||
ARC_CHORD, // Current mode for creation is arc by chord
|
|
||||||
ARC_CHORD_END,// Chord validated, waiting for radius or center
|
|
||||||
END_SKETCH // End sketch
|
|
||||||
};
|
};
|
Loading…
Reference in New Issue
Block a user