use constraint to limit minimum and maximum degree
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
# include <BRepAdaptor_CompCurve.hxx>
|
||||
# include <BRepAdaptor_HCompCurve.hxx>
|
||||
# include <BRepLib_MakeWire.hxx>
|
||||
# include <Geom_BSplineSurface.hxx>
|
||||
# include <TopoDS.hxx>
|
||||
# include <TopoDS_Face.hxx>
|
||||
# include <TopoDS_Shell.hxx>
|
||||
@@ -256,6 +257,8 @@ App::DocumentObjectExecReturn *RuledSurface::execute(void)
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
App::PropertyIntegerConstraint::Constraints Loft::Degrees = {2,Geom_BSplineSurface::MaxDegree(),1};
|
||||
|
||||
PROPERTY_SOURCE(Part::Loft, Part::Feature)
|
||||
|
||||
Loft::Loft()
|
||||
@@ -266,6 +269,7 @@ Loft::Loft()
|
||||
ADD_PROPERTY_TYPE(Ruled,(false),"Loft",App::Prop_None,"Ruled surface");
|
||||
ADD_PROPERTY_TYPE(Closed,(false),"Loft",App::Prop_None,"Close Last to First Profile");
|
||||
ADD_PROPERTY_TYPE(MaxDegree,(5),"Loft",App::Prop_None,"Maximum Degree");
|
||||
MaxDegree.setConstraints(&Degrees);
|
||||
}
|
||||
|
||||
short Loft::mustExecute() const
|
||||
|
||||
@@ -73,7 +73,7 @@ public:
|
||||
App::PropertyBool Solid;
|
||||
App::PropertyBool Ruled;
|
||||
App::PropertyBool Closed;
|
||||
App::PropertyInteger MaxDegree;
|
||||
App::PropertyIntegerConstraint MaxDegree;
|
||||
|
||||
/** @name methods override feature */
|
||||
//@{
|
||||
@@ -87,6 +87,9 @@ public:
|
||||
|
||||
protected:
|
||||
void onChanged (const App::Property* prop);
|
||||
|
||||
private:
|
||||
static App::PropertyIntegerConstraint::Constraints Degrees;
|
||||
};
|
||||
|
||||
class Sweep : public Part::Feature
|
||||
|
||||
@@ -2090,11 +2090,11 @@ TopoDS_Shape TopoShape::makeLoft(const TopTools_ListOfShape& profiles,
|
||||
Standard_Boolean isSolid,
|
||||
Standard_Boolean isRuled,
|
||||
Standard_Boolean isClosed,
|
||||
Standard_Integer MaxDegree) const
|
||||
Standard_Integer maxDegree) const
|
||||
{
|
||||
// http://opencascade.blogspot.com/2010/01/surface-modeling-part5.html
|
||||
BRepOffsetAPI_ThruSections aGenerator (isSolid,isRuled);
|
||||
aGenerator.SetMaxDegree(MaxDegree);
|
||||
aGenerator.SetMaxDegree(maxDegree);
|
||||
|
||||
TopTools_ListIteratorOfListOfShape it;
|
||||
int countShapes = 0;
|
||||
@@ -2116,7 +2116,8 @@ TopoDS_Shape TopoShape::makeLoft(const TopTools_ListOfShape& profiles,
|
||||
}
|
||||
|
||||
if (countShapes < 2) {
|
||||
Standard_Failure::Raise("Need at least two vertices, edges or wires to create loft face"); }
|
||||
Standard_Failure::Raise("Need at least two vertices, edges or wires to create loft face");
|
||||
}
|
||||
else {
|
||||
// close loft by duplicating initial profile as last profile. not perfect.
|
||||
if (isClosed) {
|
||||
@@ -2125,8 +2126,9 @@ TopoDS_Shape TopoShape::makeLoft(const TopTools_ListOfShape& profiles,
|
||||
- V1-W1-W2-W3 ==> V1-W1-W2-W3-V1 valid closed
|
||||
- W1-W2-W3-V1 ==> W1-W2-W3-V1-W1 invalid closed
|
||||
- W1-W2-W3 ==> W1-W2-W3-W1 valid closed*/
|
||||
if (profiles.Last().ShapeType() == TopAbs_VERTEX) {
|
||||
Base::Console().Message("TopoShape::makeLoft: can't close Loft with Vertex as last profile. 'Closed' ignored.\n"); }
|
||||
if (profiles.Last().ShapeType() == TopAbs_VERTEX) {
|
||||
Base::Console().Message("TopoShape::makeLoft: can't close Loft with Vertex as last profile. 'Closed' ignored.\n");
|
||||
}
|
||||
else {
|
||||
// repeat Add logic above for first profile
|
||||
const TopoDS_Shape& firstProfile = profiles.First();
|
||||
@@ -2135,12 +2137,12 @@ TopoDS_Shape TopoShape::makeLoft(const TopTools_ListOfShape& profiles,
|
||||
countShapes++;
|
||||
}
|
||||
else if (firstProfile.ShapeType() == TopAbs_EDGE) {
|
||||
aGenerator.AddWire(TopoDS::Wire (firstProfile));
|
||||
countShapes++;
|
||||
aGenerator.AddWire(TopoDS::Wire (firstProfile));
|
||||
countShapes++;
|
||||
}
|
||||
else if (firstProfile.ShapeType() == TopAbs_WIRE) {
|
||||
aGenerator.AddWire(TopoDS::Wire (firstProfile));
|
||||
countShapes++;
|
||||
aGenerator.AddWire(TopoDS::Wire (firstProfile));
|
||||
countShapes++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2151,7 +2153,7 @@ TopoDS_Shape TopoShape::makeLoft(const TopTools_ListOfShape& profiles,
|
||||
aGenerator.Build();
|
||||
if (!aGenerator.IsDone())
|
||||
Standard_Failure::Raise("Failed to create loft face");
|
||||
|
||||
|
||||
//Base::Console().Message("DEBUG: TopoShape::makeLoft returns.\n");
|
||||
return aGenerator.Shape();
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@ public:
|
||||
TopoDS_Shape makeThread(Standard_Real pitch, Standard_Real depth,
|
||||
Standard_Real height, Standard_Real radius) const;
|
||||
TopoDS_Shape makeLoft(const TopTools_ListOfShape& profiles, Standard_Boolean isSolid,
|
||||
Standard_Boolean isRuled, Standard_Boolean isClosed = Standard_False, Standard_Integer MaxDegree = 5) const;
|
||||
Standard_Boolean isRuled, Standard_Boolean isClosed = Standard_False, Standard_Integer maxDegree = 5) const;
|
||||
TopoDS_Shape makeOffsetShape(double offset, double tol,
|
||||
bool intersection = false, bool selfInter = false,
|
||||
short offsetMode = 0, short join = 0, bool fill = false) const;
|
||||
|
||||
Reference in New Issue
Block a user