+ make surface module compile with v0.17 and occ 7
This commit is contained in:
@@ -49,28 +49,25 @@ using namespace Surface;
|
||||
|
||||
PROPERTY_SOURCE(Surface::BSplineSurf, Surface::BSurf)
|
||||
|
||||
//Initial values
|
||||
|
||||
BSplineSurf::BSplineSurf() : BSurf()
|
||||
{
|
||||
}
|
||||
|
||||
//Functions
|
||||
|
||||
App::DocumentObjectExecReturn *BSplineSurf::execute(void)
|
||||
{
|
||||
correcteInvalidFillType();
|
||||
//Begin Construction
|
||||
try{
|
||||
Handle_Geom_BSplineCurve crvs[4];
|
||||
TopoDS_Wire aWire; //Create empty wire
|
||||
std::vector<Handle_Geom_BSplineCurve> crvs;
|
||||
crvs.reserve(4);
|
||||
TopoDS_Wire aWire;
|
||||
|
||||
//Gets the healed wire
|
||||
getWire(aWire);
|
||||
|
||||
Standard_Real u1, u2; // contains output
|
||||
TopExp_Explorer anExp (aWire, TopAbs_EDGE);
|
||||
int it = 0;
|
||||
for (; anExp.More(); anExp.Next()) {
|
||||
const TopoDS_Edge& edge = TopoDS::Edge (anExp.Current());
|
||||
TopLoc_Location heloc; // this will be output
|
||||
@@ -81,7 +78,7 @@ App::DocumentObjectExecReturn *BSplineSurf::execute(void)
|
||||
gp_Trsf transf = heloc.Transformation();
|
||||
b_geom->Transform(transf); // apply original transformation to control points
|
||||
//Store Underlying Geometry
|
||||
crvs[it] = b_geom;
|
||||
crvs.push_back(b_geom);
|
||||
}
|
||||
else {
|
||||
// try to convert it into a b-spline
|
||||
@@ -96,36 +93,39 @@ App::DocumentObjectExecReturn *BSplineSurf::execute(void)
|
||||
gp_Trsf transf = heloc2.Transformation();
|
||||
b_geom2->Transform(transf); // apply original transformation to control points
|
||||
//Store Underlying Geometry
|
||||
crvs[it] = b_geom2;
|
||||
crvs.push_back(b_geom2);
|
||||
}
|
||||
else {
|
||||
Standard_Failure::Raise("A curve was not a b-spline and could not be converted into one.");
|
||||
}
|
||||
}
|
||||
it++;
|
||||
}
|
||||
|
||||
GeomFill_FillingStyle fstyle = getFillingStyle();
|
||||
GeomFill_BSplineCurves aSurfBuilder; //Create Surface Builder
|
||||
if(edgeCount==2) {aSurfBuilder.Init(crvs[0], crvs[1], fstyle);}
|
||||
else if(edgeCount==3) {aSurfBuilder.Init(crvs[0], crvs[1], crvs[2], fstyle);}
|
||||
else if(edgeCount==4) {aSurfBuilder.Init(crvs[0], crvs[1], crvs[2], crvs[3], fstyle);}
|
||||
if(edgeCount==2) {
|
||||
aSurfBuilder.Init(crvs[0], crvs[1], fstyle);
|
||||
}
|
||||
else if(edgeCount==3) {
|
||||
aSurfBuilder.Init(crvs[0], crvs[1], crvs[2], fstyle);
|
||||
}
|
||||
else if(edgeCount==4) {
|
||||
aSurfBuilder.Init(crvs[0], crvs[1], crvs[2], crvs[3], fstyle);
|
||||
}
|
||||
|
||||
createFace(aSurfBuilder.Surface());
|
||||
//createFace(aSurfBuilder.Surface());
|
||||
|
||||
return App::DocumentObject::StdReturn;
|
||||
|
||||
} //End Try
|
||||
catch(Standard_ConstructionError) {
|
||||
}
|
||||
catch (Standard_ConstructionError) {
|
||||
// message is in a Latin language, show a normal one
|
||||
return new App::DocumentObjectExecReturn("Curves are disjoint.");
|
||||
}
|
||||
catch(StdFail_NotDone) {
|
||||
catch (StdFail_NotDone) {
|
||||
return new App::DocumentObjectExecReturn("A curve was not a b-spline and could not be converted into one.");
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
return new App::DocumentObjectExecReturn(e->GetMessageString());
|
||||
} //End Catch
|
||||
|
||||
} //End execute
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,5 +39,7 @@ public:
|
||||
// recalculate the feature
|
||||
virtual App::DocumentObjectExecReturn *execute(void);
|
||||
};
|
||||
|
||||
}//Namespace Surface
|
||||
|
||||
#endif
|
||||
|
||||
@@ -30,8 +30,8 @@
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopoDS_Wire.hxx>
|
||||
#include <BRepBuilderAPI_Copy.hxx>
|
||||
#include <Geom_BezierCurve.hxx>
|
||||
#include <GeomFill_BezierCurves.hxx>
|
||||
#include <Geom_BoundedSurface.hxx>
|
||||
#include <BRepBuilderAPI_MakeFace.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
@@ -51,13 +51,13 @@ void ShapeValidator::initValidator(void)
|
||||
}
|
||||
|
||||
// shows error message if the shape is not an edge
|
||||
bool ShapeValidator::checkEdge(const TopoDS_Shape& shape)
|
||||
void ShapeValidator::checkEdge(const TopoDS_Shape& shape)
|
||||
{
|
||||
if (shape.IsNull() || shape.ShapeType() != TopAbs_EDGE)
|
||||
{
|
||||
Standard_Failure::Raise("Shape is not an edge.");
|
||||
return false;
|
||||
}
|
||||
|
||||
TopoDS_Edge etmp = TopoDS::Edge(shape); //Curve TopoDS_Edge
|
||||
TopLoc_Location heloc; // this will be output
|
||||
Standard_Real u0;// contains output
|
||||
@@ -67,10 +67,9 @@ bool ShapeValidator::checkEdge(const TopoDS_Shape& shape)
|
||||
if (bez_geom.IsNull())
|
||||
{
|
||||
// this one is not Bezier, we hope it can be converted into b-spline
|
||||
if(willBezier) {
|
||||
if (willBezier) {
|
||||
// already found the other type, fail
|
||||
Standard_Failure::Raise("Mixing Bezier and non-Bezier curves is not allowed.");
|
||||
return false;
|
||||
}
|
||||
// we will create b-spline surface
|
||||
willBSpline = true;
|
||||
@@ -78,25 +77,21 @@ bool ShapeValidator::checkEdge(const TopoDS_Shape& shape)
|
||||
else
|
||||
{
|
||||
// this one is Bezier
|
||||
if(willBSpline) {
|
||||
if (willBSpline) {
|
||||
// already found the other type, fail
|
||||
Standard_Failure::Raise("Mixing Bezier and non-Bezier curves is not allowed.");
|
||||
return false;
|
||||
}
|
||||
// we will create Bezier surface
|
||||
willBezier = true;
|
||||
}
|
||||
|
||||
edgeCount++;
|
||||
return true;
|
||||
}
|
||||
|
||||
void ShapeValidator::checkAndAdd(const TopoDS_Shape &shape, Handle(ShapeExtend_WireData) *aWD)
|
||||
{
|
||||
if(!checkEdge(shape))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(aWD != NULL)
|
||||
checkEdge(shape);
|
||||
if (aWD != NULL)
|
||||
{
|
||||
BRepBuilderAPI_Copy copier(shape);
|
||||
// make a copy of the shape and the underlying geometry to avoid to affect the input shapes
|
||||
@@ -131,20 +126,19 @@ void ShapeValidator::checkAndAdd(const Part::TopoShape &ts, const char *subName,
|
||||
}
|
||||
catch(Standard_Failure) { // any OCC exception means an unappropriate shape in the selection
|
||||
Standard_Failure::Raise("Wrong shape type.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PROPERTY_SOURCE(Surface::BSurf, Part::Feature)
|
||||
|
||||
const char* BSurf::FillTypeEnums[] = {"Invalid", "Sretched", "Coons", "Curved", NULL};
|
||||
const char* BSurf::FillTypeEnums[] = {"Invalid", "Stretched", "Coons", "Curved", NULL};
|
||||
|
||||
BSurf::BSurf(): Feature()
|
||||
{
|
||||
ADD_PROPERTY(FillType, ((long)0));
|
||||
ADD_PROPERTY(BoundaryList, (0, "Dummy"));
|
||||
FillType.StatusBits |= 4; // read-only in property editor
|
||||
FillType.setStatus(App::Property::ReadOnly, true); // read-only in property editor
|
||||
FillType.setEnums(FillTypeEnums);
|
||||
}
|
||||
|
||||
@@ -164,10 +158,15 @@ GeomFill_FillingStyle BSurf::getFillingStyle()
|
||||
{
|
||||
//Identify filling style
|
||||
int ftype = FillType.getValue();
|
||||
if(ftype==StretchStyle) {return GeomFill_StretchStyle;}
|
||||
else if(ftype==CoonsStyle) {return GeomFill_CoonsStyle;}
|
||||
else if(ftype==CurvedStyle) {return GeomFill_CurvedStyle;}
|
||||
else {Standard_Failure::Raise("Filling style must be 1 (Stretch), 2 (Coons), or 3 (Curved).");}
|
||||
if (ftype==StretchStyle)
|
||||
return GeomFill_StretchStyle;
|
||||
else if(ftype==CoonsStyle)
|
||||
return GeomFill_CoonsStyle;
|
||||
else if(ftype==CurvedStyle)
|
||||
return GeomFill_CurvedStyle;
|
||||
else
|
||||
Standard_Failure::Raise("Filling style must be 1 (Stretch), 2 (Coons), or 3 (Curved).");
|
||||
throw; // this is to shut up the compiler
|
||||
}
|
||||
|
||||
|
||||
@@ -176,29 +175,32 @@ void BSurf::getWire(TopoDS_Wire& aWire)
|
||||
Handle(ShapeFix_Wire) aShFW = new ShapeFix_Wire;
|
||||
Handle(ShapeExtend_WireData) aWD = new ShapeExtend_WireData;
|
||||
|
||||
int boundaryListSize = BoundaryList.getSize();
|
||||
if(boundaryListSize > 4) // if too many not even try
|
||||
std::vector<App::PropertyLinkSubList::SubSet> boundary = BoundaryList.getSubListValues();
|
||||
if(boundary.size() > 4) // if too many not even try
|
||||
{
|
||||
Standard_Failure::Raise("Only 2-4 curves are allowed");
|
||||
return;
|
||||
}
|
||||
|
||||
initValidator();
|
||||
for(int i = 0; i < boundaryListSize; i++)
|
||||
for(std::size_t i = 0; i < boundary.size(); i++)
|
||||
{
|
||||
App::PropertyLinkSubList::SubSet set = BoundaryList[i];
|
||||
App::PropertyLinkSubList::SubSet set = boundary[i];
|
||||
|
||||
if(set.obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
|
||||
if(set.first->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
|
||||
|
||||
const Part::TopoShape &ts = static_cast<Part::Feature*>(set.obj)->Shape.getShape();
|
||||
checkAndAdd(ts, set.sub, &aWD);
|
||||
for (auto jt: set.second) {
|
||||
const Part::TopoShape &ts = static_cast<Part::Feature*>(set.first)->Shape.getShape();
|
||||
checkAndAdd(ts, jt.c_str(), &aWD);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Standard_Failure::Raise("Curve not from Part::Feature");
|
||||
}
|
||||
else{Standard_Failure::Raise("Curve not from Part::Feature");return;}
|
||||
}
|
||||
|
||||
if(edgeCount < 2 || edgeCount > 4)
|
||||
{
|
||||
Standard_Failure::Raise("Only 2-4 curves are allowed");
|
||||
return;
|
||||
}
|
||||
|
||||
//Reorder the curves and fix the wire if required
|
||||
@@ -212,7 +214,9 @@ void BSurf::getWire(TopoDS_Wire& aWire)
|
||||
|
||||
aWire = aShFW->Wire(); //Healed Wire
|
||||
|
||||
if(aWire.IsNull()){Standard_Failure::Raise("Wire unable to be constructed");return;}
|
||||
if(aWire.IsNull()) {
|
||||
Standard_Failure::Raise("Wire unable to be constructed");
|
||||
}
|
||||
}
|
||||
|
||||
void BSurf::createFace(const Handle_Geom_BoundedSurface &aSurface)
|
||||
@@ -225,8 +229,12 @@ void BSurf::createFace(const Handle_Geom_BoundedSurface &aSurface)
|
||||
|
||||
TopoDS_Face aFace = aFaceBuilder.Face();
|
||||
|
||||
if(!aFaceBuilder.IsDone()) { Standard_Failure::Raise("Face unable to be constructed");}
|
||||
if (aFace.IsNull()) { Standard_Failure::Raise("Resulting Face is null"); }
|
||||
if(!aFaceBuilder.IsDone()) {
|
||||
Standard_Failure::Raise("Face unable to be constructed");
|
||||
}
|
||||
if (aFace.IsNull()) {
|
||||
Standard_Failure::Raise("Resulting Face is null");
|
||||
}
|
||||
this->Shape.setValue(aFace);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,21 +24,20 @@
|
||||
#ifndef FEATUREBSURF_H
|
||||
#define FEATUREBSURF_H
|
||||
|
||||
#include <Geom_BoundedSurface.hxx>
|
||||
#include <GeomFill_FillingStyle.hxx>
|
||||
#include <ShapeExtend_WireData.hxx>
|
||||
|
||||
#include <App/PropertyStandard.h>
|
||||
#include <App/PropertyUnits.h>
|
||||
#include <App/PropertyLinks.h>
|
||||
#include "Mod/Part/App/PartFeature.h"
|
||||
#include "Mod/Surface/FillType.h"
|
||||
|
||||
class Handle_Geom_BoundedSurface;
|
||||
#include <Mod/Part/App/PartFeature.h>
|
||||
#include <Mod/Surface/FillType.h>
|
||||
|
||||
namespace Surface
|
||||
{
|
||||
|
||||
class ShapeValidator
|
||||
class SurfaceExport ShapeValidator
|
||||
{
|
||||
protected:
|
||||
bool willBezier;
|
||||
@@ -46,7 +45,7 @@ protected:
|
||||
int edgeCount;
|
||||
|
||||
void initValidator(void);
|
||||
bool checkEdge(const TopoDS_Shape& shape);
|
||||
void checkEdge(const TopoDS_Shape& shape);
|
||||
void checkAndAdd(const TopoDS_Shape &shape, Handle(ShapeExtend_WireData) *aWD = NULL);
|
||||
void checkAndAdd(const Part::TopoShape &ts, const char *subName, Handle(ShapeExtend_WireData) *aWire = NULL);
|
||||
};
|
||||
@@ -57,7 +56,7 @@ class BSurf : public Part::Feature, public ShapeValidator
|
||||
|
||||
public:
|
||||
BSurf();
|
||||
App::PropertyLinkSubList BoundaryList; //curves to be turned into a face (2-4 curves allowed).
|
||||
App::PropertyLinkSubList BoundaryList; //curves to be turned into a face (2-4 curves allowed).
|
||||
App::PropertyEnumeration FillType; //Fill method (1, 2, or 3 for Stretch, Coons, and Curved)
|
||||
|
||||
short mustExecute() const;
|
||||
|
||||
@@ -47,28 +47,24 @@ using namespace Surface;
|
||||
|
||||
PROPERTY_SOURCE(Surface::BezSurf, Surface::BSurf)
|
||||
|
||||
//Initial values
|
||||
|
||||
BezSurf::BezSurf() : BSurf()
|
||||
{
|
||||
}
|
||||
|
||||
//Functions
|
||||
|
||||
App::DocumentObjectExecReturn *BezSurf::execute(void)
|
||||
{
|
||||
correcteInvalidFillType();
|
||||
//Begin Construction
|
||||
try{
|
||||
Handle_Geom_BezierCurve crvs[4];
|
||||
TopoDS_Wire aWire; //Create empty wire
|
||||
|
||||
try {
|
||||
std::vector<Handle_Geom_BezierCurve> crvs;
|
||||
crvs.reserve(4);
|
||||
TopoDS_Wire aWire;
|
||||
|
||||
//Gets the healed wire
|
||||
getWire(aWire);
|
||||
|
||||
Standard_Real u1, u2; // contains output
|
||||
TopExp_Explorer anExp (aWire, TopAbs_EDGE);
|
||||
int it = 0;
|
||||
for (; anExp.More(); anExp.Next()) {
|
||||
const TopoDS_Edge hedge = TopoDS::Edge (anExp.Current());
|
||||
TopLoc_Location heloc; // this will be output
|
||||
@@ -79,34 +75,35 @@ App::DocumentObjectExecReturn *BezSurf::execute(void)
|
||||
gp_Trsf transf = heloc.Transformation();
|
||||
b_geom->Transform(transf); // apply original transformation to control points
|
||||
//Store Underlying Geometry
|
||||
crvs[it] = b_geom;
|
||||
crvs.push_back(b_geom);
|
||||
}
|
||||
else {
|
||||
Standard_Failure::Raise("Curve not a Bezier Curve");
|
||||
}
|
||||
it++;
|
||||
}
|
||||
|
||||
GeomFill_FillingStyle fstyle = getFillingStyle();
|
||||
GeomFill_BezierCurves aSurfBuilder; //Create Surface Builder
|
||||
if(edgeCount==2) {aSurfBuilder.Init(crvs[0], crvs[1], fstyle);}
|
||||
else if(edgeCount==3) {aSurfBuilder.Init(crvs[0], crvs[1], crvs[2], fstyle);}
|
||||
else if(edgeCount==4) {aSurfBuilder.Init(crvs[0], crvs[1], crvs[2], crvs[3], fstyle);}
|
||||
if (edgeCount == 2) {
|
||||
aSurfBuilder.Init(crvs[0], crvs[1], fstyle);
|
||||
}
|
||||
else if(edgeCount == 3) {
|
||||
aSurfBuilder.Init(crvs[0], crvs[1], crvs[2], fstyle);
|
||||
}
|
||||
else if(edgeCount == 4) {
|
||||
aSurfBuilder.Init(crvs[0], crvs[1], crvs[2], crvs[3], fstyle);
|
||||
}
|
||||
|
||||
createFace(aSurfBuilder.Surface());
|
||||
//createFace(aSurfBuilder.Surface());
|
||||
|
||||
return App::DocumentObject::StdReturn;
|
||||
|
||||
} //End Try
|
||||
catch(Standard_ConstructionError) {
|
||||
}
|
||||
catch (Standard_ConstructionError) {
|
||||
// message is in a Latin language, show a normal one
|
||||
return new App::DocumentObjectExecReturn("Curves are disjoint.");
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
return new App::DocumentObjectExecReturn(e->GetMessageString());
|
||||
} //End Catch
|
||||
|
||||
} //End execute
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,5 +39,7 @@ public:
|
||||
// recalculate the feature
|
||||
virtual App::DocumentObjectExecReturn *execute(void);
|
||||
};
|
||||
|
||||
}//Namespace Surface
|
||||
|
||||
#endif
|
||||
|
||||
@@ -45,21 +45,21 @@ PROPERTY_SOURCE(Surface::Cut, Part::Feature)
|
||||
|
||||
Cut::Cut()
|
||||
{
|
||||
ADD_PROPERTY(aShapeList,(0,"TopoDS_Shape"));
|
||||
|
||||
ADD_PROPERTY(ShapeList,(0,"TopoDS_Shape"));
|
||||
}
|
||||
|
||||
//Check if any components of the surface have been modified
|
||||
|
||||
short Cut::mustExecute() const
|
||||
{
|
||||
if (aShapeList.isTouched())
|
||||
if (ShapeList.isTouched())
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
App::DocumentObjectExecReturn *Cut::execute(void)
|
||||
{
|
||||
#if 0
|
||||
|
||||
//Perform error checking
|
||||
|
||||
@@ -113,5 +113,7 @@ App::DocumentObjectExecReturn *Cut::execute(void)
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
return new App::DocumentObjectExecReturn(e->GetMessageString());
|
||||
} //End Catch
|
||||
#endif
|
||||
return 0;
|
||||
|
||||
} //End execute
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include <App/PropertyStandard.h>
|
||||
#include <App/PropertyUnits.h>
|
||||
#include <App/PropertyLinks.h>
|
||||
#include "Mod/Part/App/PartFeature.h"
|
||||
#include <Mod/Part/App/PartFeature.h>
|
||||
|
||||
namespace Surface
|
||||
{
|
||||
@@ -38,7 +38,7 @@ class SurfaceExport Cut : public Part::Feature
|
||||
public:
|
||||
Cut();
|
||||
|
||||
App::PropertyLinkSubList aShapeList; //Shapes to be cut.
|
||||
App::PropertyLinkSubList ShapeList; //Shapes to be cut.
|
||||
|
||||
// recalculate the feature
|
||||
App::DocumentObjectExecReturn *execute(void);
|
||||
@@ -49,5 +49,7 @@ public:
|
||||
// }
|
||||
|
||||
};
|
||||
|
||||
}//Namespace Surface
|
||||
|
||||
#endif
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <Base/Tools.h>
|
||||
#include <Base/Exception.h>
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
|
||||
using namespace Surface;
|
||||
|
||||
@@ -132,9 +132,6 @@ App::DocumentObjectExecReturn *Filling::execute(void)
|
||||
|
||||
BRepFill_Filling builder(Deg,NPOC,NI,Anis,T2d,T3d,TG1,TG2,Mdeg,Mseg);
|
||||
|
||||
//Check that borders are defined
|
||||
printf("Surface Filling\n");
|
||||
|
||||
if((Border.getSize())<1){return new App::DocumentObjectExecReturn("Border must have at least one curve defined.");}
|
||||
|
||||
//Assign Boundaries
|
||||
@@ -292,6 +289,7 @@ void appconstr_bface(BRepFill_Filling& builder,const App::PropertyLinkSubList& a
|
||||
*/
|
||||
void appconstr_crvface(BRepFill_Filling& builder, const App::PropertyLinkSubList& anEdge, const App::PropertyLinkSubList& aFace, const App::PropertyIntegerList& Order, Standard_Boolean bnd){
|
||||
|
||||
#if 0
|
||||
int res;
|
||||
|
||||
GeomAbs_Shape ordtmp;
|
||||
@@ -383,12 +381,12 @@ void appconstr_crvface(BRepFill_Filling& builder, const App::PropertyLinkSubList
|
||||
bc++;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
void appconstr_pt(BRepFill_Filling& builder,const App::PropertyLinkSubList& aVertex){
|
||||
|
||||
#if 0
|
||||
int res;
|
||||
|
||||
for(int i=0; i<aVertex.getSize(); i++) {
|
||||
@@ -420,11 +418,12 @@ void appconstr_pt(BRepFill_Filling& builder,const App::PropertyLinkSubList& aVer
|
||||
res = builder.Add(BRep_Tool::Pnt(vtmp));
|
||||
|
||||
}
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
void appinitface(BRepFill_Filling& builder,const App::PropertyLinkSubList& aFace){
|
||||
|
||||
#if 0
|
||||
if(aFace.getSize()>1){Standard_Failure::Raise("Only one face may be used for the initial face");return;}
|
||||
|
||||
Part::TopoShape ts;
|
||||
@@ -452,6 +451,6 @@ void appinitface(BRepFill_Filling& builder,const App::PropertyLinkSubList& aFace
|
||||
else{Standard_Failure::Raise("Point not from Part::Feature");}
|
||||
|
||||
builder.LoadInitSurface(face);
|
||||
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -73,5 +73,7 @@ public:
|
||||
// }
|
||||
|
||||
};
|
||||
|
||||
} //Namespace Surface
|
||||
|
||||
#endif
|
||||
|
||||
@@ -43,110 +43,76 @@ PROPERTY_SOURCE(Surface::Sewing, Part::Feature)
|
||||
|
||||
Sewing::Sewing()
|
||||
{
|
||||
ADD_PROPERTY(aShapeList,(0,"TopoDS_Shape"));
|
||||
|
||||
App::PropertyFloat tol;
|
||||
App::PropertyBool sewopt; //Option for sewing (if false only control)
|
||||
App::PropertyBool degenshp; //Option for analysis of degenerated shapes
|
||||
App::PropertyBool cutfreeedges; //Option for cutting of free edges
|
||||
App::PropertyBool nonmanifold; //Option for non-manifold processing
|
||||
|
||||
ADD_PROPERTY(tol,(0.0000001));
|
||||
ADD_PROPERTY(sewopt,(true));
|
||||
ADD_PROPERTY(degenshp,(true));
|
||||
ADD_PROPERTY(cutfreeedges,(true));
|
||||
ADD_PROPERTY(nonmanifold,(false));
|
||||
ADD_PROPERTY(ShapeList,(0,"TopoDS_Shape"));
|
||||
|
||||
ADD_PROPERTY(Tolerance,(0.0000001));
|
||||
ADD_PROPERTY(SewingOption,(true));
|
||||
ADD_PROPERTY(DegenerateShape,(true));
|
||||
ADD_PROPERTY(CutFreeEdges,(true));
|
||||
ADD_PROPERTY(Nonmanifold,(false));
|
||||
}
|
||||
|
||||
//Function Definitions
|
||||
|
||||
void addshape(BRepBuilderAPI_Sewing& builder,const App::PropertyLinkSubList& aShapeList);
|
||||
|
||||
//Check if any components of the surface have been modified
|
||||
|
||||
short Sewing::mustExecute() const
|
||||
{
|
||||
if (aShapeList.isTouched() ||
|
||||
tol.isTouched() ||
|
||||
sewopt.isTouched() ||
|
||||
degenshp.isTouched() ||
|
||||
cutfreeedges.isTouched() ||
|
||||
nonmanifold.isTouched())
|
||||
if (ShapeList.isTouched() ||
|
||||
Tolerance.isTouched() ||
|
||||
SewingOption.isTouched() ||
|
||||
DegenerateShape.isTouched() ||
|
||||
CutFreeEdges.isTouched() ||
|
||||
Nonmanifold.isTouched())
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
App::DocumentObjectExecReturn *Sewing::execute(void)
|
||||
{
|
||||
|
||||
//Assign Variables
|
||||
|
||||
double atol = tol.getValue();
|
||||
bool opt1 = sewopt.getValue();
|
||||
bool opt2 = degenshp.getValue();
|
||||
bool opt3 = cutfreeedges.getValue();
|
||||
bool opt4 = nonmanifold.getValue();
|
||||
|
||||
//Perform error checking
|
||||
double atol = Tolerance.getValue();
|
||||
bool opt1 = SewingOption.getValue();
|
||||
bool opt2 = DegenerateShape.getValue();
|
||||
bool opt3 = CutFreeEdges.getValue();
|
||||
bool opt4 = Nonmanifold.getValue();
|
||||
|
||||
|
||||
//Begin Construction
|
||||
try{
|
||||
|
||||
try {
|
||||
BRepBuilderAPI_Sewing builder(atol,opt1,opt2,opt3,opt4);
|
||||
|
||||
addshape(builder,aShapeList);
|
||||
std::vector<App::PropertyLinkSubList::SubSet> subset = ShapeList.getSubListValues();
|
||||
for(std::vector<App::PropertyLinkSubList::SubSet>::iterator it = subset.begin(); it != subset.end(); ++it) {
|
||||
// the subset has the documentobject and the element name which belongs to it,
|
||||
// in our case for example the cube object and the "Edge1" string
|
||||
if (it->first->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
|
||||
//we get the shape of the document object which resemble the whole box
|
||||
Part::TopoShape ts = static_cast<Part::Feature*>(it->first)->Shape.getShape();
|
||||
|
||||
//we want only the subshape which is linked
|
||||
for (auto jt: it->second) {
|
||||
TopoDS_Shape sub = ts.getSubShape(jt.c_str());
|
||||
builder.Add(sub);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Standard_Failure::Raise("Shape item not from Part::Feature");
|
||||
}
|
||||
}
|
||||
|
||||
builder.Perform(); //Perform Sewing
|
||||
|
||||
TopoDS_Shape aShape = builder.SewedShape(); //Get Shape
|
||||
|
||||
printf("number of degenerated shapes: %i\n",builder.NbDegeneratedShapes());
|
||||
printf("number of deleted faces: %i\n",builder.NbDeletedFaces());
|
||||
printf("number of free edges: %i\n",builder.NbFreeEdges());
|
||||
printf("number of multiple edges: %i\n",builder.NbMultipleEdges());
|
||||
printf("number of continuous edges: %i\n",builder.NbContigousEdges());
|
||||
//printf("number of degenerated shapes: %i\n",builder.NbDegeneratedShapes());
|
||||
//printf("number of deleted faces: %i\n",builder.NbDeletedFaces());
|
||||
//printf("number of free edges: %i\n",builder.NbFreeEdges());
|
||||
//printf("number of multiple edges: %i\n",builder.NbMultipleEdges());
|
||||
//printf("number of continuous edges: %i\n",builder.NbContigousEdges());
|
||||
|
||||
if (aShape.IsNull())
|
||||
return new App::DocumentObjectExecReturn("Resulting shape is null");
|
||||
this->Shape.setValue(aShape);
|
||||
return 0;
|
||||
} //End Try
|
||||
return StdReturn;
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
return new App::DocumentObjectExecReturn(e->GetMessageString());
|
||||
} //End Catch
|
||||
|
||||
} //End execute
|
||||
|
||||
void addshape(BRepBuilderAPI_Sewing& builder,const App::PropertyLinkSubList& aShapeList){
|
||||
|
||||
for(int i=0; i<aShapeList.getSize(); i++) {
|
||||
|
||||
printf("Processing shape %i\n",i);
|
||||
|
||||
Part::TopoShape ts;
|
||||
// Part::TopoShape sub;
|
||||
TopoDS_Shape sub;
|
||||
std::vector< const char * > temp;
|
||||
|
||||
//the subset has the documentobject and the element name which belongs to it,
|
||||
// in our case for example the cube object and the "Edge1" string
|
||||
App::PropertyLinkSubList::SubSet set = aShapeList[i];
|
||||
|
||||
//set.obj should be our box, but just to make sure no one set something stupid
|
||||
if(set.obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
|
||||
|
||||
//we get the shape of the document object which resemble the whole box
|
||||
ts = static_cast<Part::Feature*>(set.obj)->Shape.getShape();
|
||||
|
||||
//we want only the subshape which is linked
|
||||
sub = ts.getSubShape(set.sub);
|
||||
}
|
||||
else{Standard_Failure::Raise("Shape item not from Part::Feature");return;}
|
||||
|
||||
builder.Add(sub);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include <App/PropertyStandard.h>
|
||||
#include <App/PropertyUnits.h>
|
||||
#include <App/PropertyLinks.h>
|
||||
#include "Mod/Part/App/PartFeature.h"
|
||||
#include <Mod/Part/App/PartFeature.h>
|
||||
|
||||
namespace Surface
|
||||
{
|
||||
@@ -38,13 +38,13 @@ class SurfaceExport Sewing : public Part::Feature
|
||||
public:
|
||||
Sewing();
|
||||
|
||||
App::PropertyLinkSubList aShapeList; //Shapes to be sewn.
|
||||
App::PropertyLinkSubList ShapeList; //Shapes to be sewn.
|
||||
|
||||
App::PropertyFloat tol;
|
||||
App::PropertyBool sewopt; //Option for sewing (if false only control)
|
||||
App::PropertyBool degenshp; //Option for analysis of degenerated shapes
|
||||
App::PropertyBool cutfreeedges; //Option for cutting of free edges
|
||||
App::PropertyBool nonmanifold; //Option for non-manifold processing
|
||||
App::PropertyFloat Tolerance;
|
||||
App::PropertyBool SewingOption; //Option for sewing (if false only control)
|
||||
App::PropertyBool DegenerateShape; //Option for analysis of degenerated shapes
|
||||
App::PropertyBool CutFreeEdges; //Option for cutting of free edges
|
||||
App::PropertyBool Nonmanifold; //Option for non-manifold processing
|
||||
|
||||
// recalculate the feature
|
||||
App::DocumentObjectExecReturn *execute(void);
|
||||
@@ -55,5 +55,7 @@ public:
|
||||
// }
|
||||
|
||||
};
|
||||
|
||||
}//Namespace Surface
|
||||
#endif
|
||||
|
||||
#endif // SURFACE_FEATURESEWING_H
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
#include <QLineEdit>
|
||||
#include <QMessageBox>
|
||||
#include <QPointer>
|
||||
#include <Standard_math.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
|
||||
@@ -30,12 +30,12 @@
|
||||
#ifdef FC_OS_WIN32
|
||||
# define PartExport __declspec(dllimport)
|
||||
# define PartGuiExport __declspec(dllimport)
|
||||
# define SurfaceAppExport __declspec(dllimport)
|
||||
# define SurfaceExport __declspec(dllimport)
|
||||
# define SurfaceGuiExport __declspec(dllexport)
|
||||
#else // for Linux
|
||||
# define PartExport
|
||||
# define PartGuiExport
|
||||
# define SurfaceAppExport
|
||||
# define SurfaceExport
|
||||
# define SurfaceGuiExport
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user