left hand helix
This commit is contained in:
parent
7c0aaa5814
commit
11358e1b86
|
@ -100,7 +100,7 @@ void Primitive::onChanged(const App::Property* prop)
|
|||
// Do not support sphere, ellipsoid and torus because the creation
|
||||
// takes too long and thus is not feasible
|
||||
std::string grp = (prop->getGroup() ? prop->getGroup() : "");
|
||||
if (grp == "Plane" || grp == "Cylinder" || grp == "Cone"){
|
||||
if (grp == "Plane" || grp == "Cylinder" || grp == "Cone" || grp == "Helix") {
|
||||
try {
|
||||
App::DocumentObjectExecReturn *ret = recompute();
|
||||
delete ret;
|
||||
|
@ -585,6 +585,8 @@ App::DocumentObjectExecReturn *Torus::execute(void)
|
|||
|
||||
PROPERTY_SOURCE(Part::Helix, Part::Primitive)
|
||||
|
||||
const char* Part::Helix::LocalCSEnums[]= {"Right-handed","Left-handed",NULL};
|
||||
|
||||
Helix::Helix(void)
|
||||
{
|
||||
ADD_PROPERTY_TYPE(Pitch, (1.0),"Helix",App::Prop_None,"The pitch of the helix");
|
||||
|
@ -595,6 +597,8 @@ Helix::Helix(void)
|
|||
Radius.setConstraints(&floatRange);
|
||||
ADD_PROPERTY_TYPE(Angle,(0.0),"Helix",App::Prop_None,"If angle is > 0 a conical otherwise a cylindircal surface is used");
|
||||
Angle.setConstraints(&apexRange);
|
||||
ADD_PROPERTY_TYPE(LocalCoord,(long(0)),"Coordinate System",App::Prop_None,"Orientation of the local coordinate system of the helix");
|
||||
LocalCoord.setEnums(LocalCSEnums);
|
||||
}
|
||||
|
||||
short Helix::mustExecute() const
|
||||
|
@ -607,6 +611,8 @@ short Helix::mustExecute() const
|
|||
return 1;
|
||||
if (Angle.isTouched())
|
||||
return 1;
|
||||
if (LocalCoord.isTouched())
|
||||
return 1;
|
||||
return Primitive::mustExecute();
|
||||
}
|
||||
|
||||
|
@ -617,8 +623,9 @@ App::DocumentObjectExecReturn *Helix::execute(void)
|
|||
Standard_Real myHeight = Height.getValue();
|
||||
Standard_Real myRadius = Radius.getValue();
|
||||
Standard_Real myAngle = Angle.getValue();
|
||||
Standard_Boolean myLocalCS = LocalCoord.getValue() ? Standard_True : Standard_False;
|
||||
TopoShape helix;
|
||||
this->Shape.setValue(helix.makeHelix(myPitch, myHeight, myRadius, myAngle));
|
||||
this->Shape.setValue(helix.makeHelix(myPitch, myHeight, myRadius, myAngle, myLocalCS));
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
|
|
|
@ -227,6 +227,7 @@ public:
|
|||
App::PropertyFloatConstraint Height;
|
||||
App::PropertyFloatConstraint Radius;
|
||||
App::PropertyFloatConstraint Angle;
|
||||
App::PropertyEnumeration LocalCoord;
|
||||
|
||||
/** @name methods override feature */
|
||||
//@{
|
||||
|
@ -234,6 +235,9 @@ public:
|
|||
App::DocumentObjectExecReturn *execute(void);
|
||||
short mustExecute() const;
|
||||
//@}
|
||||
|
||||
private:
|
||||
static const char* LocalCSEnums[];
|
||||
};
|
||||
|
||||
class PartExport Wedge : public Primitive
|
||||
|
|
|
@ -1493,42 +1493,49 @@ TopoDS_Shape TopoShape::makeSweep(const TopoDS_Shape& profile, double tol, int f
|
|||
}
|
||||
|
||||
TopoDS_Shape TopoShape::makeHelix(Standard_Real pitch, Standard_Real height,
|
||||
Standard_Real radius, Standard_Real angle) const
|
||||
Standard_Real radius, Standard_Real angle,
|
||||
Standard_Boolean leftHanded) const
|
||||
{
|
||||
if (pitch < Precision::Confusion())
|
||||
Standard_Failure::Raise("Pitch of helix too small");
|
||||
if (pitch < Precision::Confusion())
|
||||
Standard_Failure::Raise("Pitch of helix too small");
|
||||
|
||||
if (height < Precision::Confusion())
|
||||
Standard_Failure::Raise("Height of helix too small");
|
||||
if (height < Precision::Confusion())
|
||||
Standard_Failure::Raise("Height of helix too small");
|
||||
|
||||
if (radius < Precision::Confusion())
|
||||
Standard_Failure::Raise("Radius of helix too small");
|
||||
if (radius < Precision::Confusion())
|
||||
Standard_Failure::Raise("Radius of helix too small");
|
||||
|
||||
gp_Ax2 cylAx2(gp_Pnt(0.0,0.0,0.0) , gp::DZ());
|
||||
Handle_Geom_Surface surf;
|
||||
if (angle < Precision::Confusion()) {
|
||||
surf = new Geom_CylindricalSurface(cylAx2, radius);
|
||||
}
|
||||
else {
|
||||
angle = Base::toRadians(angle);
|
||||
if (angle < Precision::Confusion())
|
||||
Standard_Failure::Raise("Angle of helix too small");
|
||||
surf = new Geom_ConicalSurface(gp_Ax3(cylAx2), angle, radius);
|
||||
}
|
||||
gp_Ax2 cylAx2(gp_Pnt(0.0,0.0,0.0) , gp::DZ());
|
||||
Handle_Geom_Surface surf;
|
||||
if (angle < Precision::Confusion()) {
|
||||
surf = new Geom_CylindricalSurface(cylAx2, radius);
|
||||
}
|
||||
else {
|
||||
angle = Base::toRadians(angle);
|
||||
if (angle < Precision::Confusion())
|
||||
Standard_Failure::Raise("Angle of helix too small");
|
||||
surf = new Geom_ConicalSurface(gp_Ax3(cylAx2), angle, radius);
|
||||
}
|
||||
|
||||
gp_Pnt2d aPnt(0, 0);
|
||||
gp_Dir2d aDir(2. * PI, pitch);
|
||||
gp_Ax2d aAx2d(aPnt, aDir);
|
||||
gp_Pnt2d aPnt(0, 0);
|
||||
gp_Dir2d aDir(2. * PI, pitch);
|
||||
if (leftHanded) {
|
||||
//aPnt.SetCoord(0.0, height);
|
||||
//aDir.SetCoord(2.0 * PI, -pitch);
|
||||
aPnt.SetCoord(2. * PI, 0.0);
|
||||
aDir.SetCoord(-2. * PI, pitch);
|
||||
}
|
||||
gp_Ax2d aAx2d(aPnt, aDir);
|
||||
|
||||
Handle(Geom2d_Line) line = new Geom2d_Line(aAx2d);
|
||||
gp_Pnt2d beg = line->Value(0);
|
||||
gp_Pnt2d end = line->Value(sqrt(4.0*PI*PI+pitch*pitch)*(height/pitch));
|
||||
Handle(Geom2d_TrimmedCurve) segm = GCE2d_MakeSegment(beg , end);
|
||||
Handle(Geom2d_Line) line = new Geom2d_Line(aAx2d);
|
||||
gp_Pnt2d beg = line->Value(0);
|
||||
gp_Pnt2d end = line->Value(sqrt(4.0*PI*PI+pitch*pitch)*(height/pitch));
|
||||
Handle(Geom2d_TrimmedCurve) segm = GCE2d_MakeSegment(beg , end);
|
||||
|
||||
TopoDS_Edge edgeOnSurf = BRepBuilderAPI_MakeEdge(segm , surf);
|
||||
TopoDS_Wire wire = BRepBuilderAPI_MakeWire(edgeOnSurf);
|
||||
BRepLib::BuildCurves3d(wire);
|
||||
return wire;
|
||||
TopoDS_Edge edgeOnSurf = BRepBuilderAPI_MakeEdge(segm , surf);
|
||||
TopoDS_Wire wire = BRepBuilderAPI_MakeWire(edgeOnSurf);
|
||||
BRepLib::BuildCurves3d(wire);
|
||||
return wire;
|
||||
}
|
||||
|
||||
TopoDS_Shape TopoShape::makeLoft(const TopTools_ListOfShape& profiles,
|
||||
|
|
|
@ -161,7 +161,7 @@ public:
|
|||
TopoDS_Shape makeTube(double radius, double tol) const;
|
||||
TopoDS_Shape makeTube() const;
|
||||
TopoDS_Shape makeHelix(Standard_Real pitch, Standard_Real height,
|
||||
Standard_Real radius, Standard_Real angle=0) const;
|
||||
Standard_Real radius, Standard_Real angle=0, Standard_Boolean left=Standard_False) const;
|
||||
TopoDS_Shape makeLoft(const TopTools_ListOfShape& profiles, Standard_Boolean isSolid,
|
||||
Standard_Boolean isRuled) const;
|
||||
TopoDS_Shape makeOffset(double offset, double tol,
|
||||
|
|
|
@ -481,12 +481,14 @@ void DlgPrimitives::createPrimitive(const QString& placement)
|
|||
"App.ActiveDocument.%1.Height=%3\n"
|
||||
"App.ActiveDocument.%1.Radius=%4\n"
|
||||
"App.ActiveDocument.%1.Angle=%5\n"
|
||||
"App.ActiveDocument.%1.Placement=%6\n")
|
||||
"App.ActiveDocument.%1.LocalCoord=%6\n"
|
||||
"App.ActiveDocument.%1.Placement=%7\n")
|
||||
.arg(name)
|
||||
.arg(ui.helixPitch->value(),0,'f',2)
|
||||
.arg(ui.helixHeight->value(),0,'f',2)
|
||||
.arg(ui.helixRadius->value(),0,'f',2)
|
||||
.arg(ui.helixAngle->value(),0,'f',2)
|
||||
.arg(ui.helixLocalCS->currentIndex())
|
||||
.arg(placement);
|
||||
}
|
||||
else if (ui.comboBox1->currentIndex() == 9) { // circle
|
||||
|
|
|
@ -1231,6 +1231,27 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_15">
|
||||
<property name="text">
|
||||
<string>Coordinate system:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QComboBox" name="helixLocalCS">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Right-handed</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Left-handed</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
|
|
Loading…
Reference in New Issue
Block a user