Added Surface module
I have added Nate's SurfaceTools module with the name changed to Surface in all files and filenames.
This commit is contained in:
73
src/Mod/Surface/App/AppSurface.cpp
Normal file
73
src/Mod/Surface/App/AppSurface.cpp
Normal file
@@ -0,0 +1,73 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2014 Nathan Miller <Nathan.A.Mill[at]gmail.com> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* 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 Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <Python.h>
|
||||
#endif
|
||||
|
||||
#include <Base/Console.h>
|
||||
#include "FeatureFilling.h"
|
||||
#include "FeatureSewing.h"
|
||||
#include "FeatureCut.h"
|
||||
#include "FeatureBezSurf.h"
|
||||
#include "FeatureBSplineSurf.h"
|
||||
|
||||
#include <Base/Interpreter.h>
|
||||
#include <Base/Parameter.h>
|
||||
|
||||
|
||||
/* registration table */
|
||||
extern struct PyMethodDef Surface_methods[];
|
||||
|
||||
PyDoc_STRVAR(module_Surface_doc,
|
||||
"This module is the Surface module.");
|
||||
|
||||
|
||||
/* Python entry */
|
||||
extern "C" {
|
||||
void SurfaceExport initSurface() {
|
||||
|
||||
try {
|
||||
Base::Interpreter().runString("import Part");
|
||||
}
|
||||
catch(const Base::Exception& e) {
|
||||
PyErr_SetString(PyExc_ImportError, e.what());
|
||||
return;
|
||||
}
|
||||
|
||||
// ADD YOUR CODE HERE
|
||||
//
|
||||
//
|
||||
(void) Py_InitModule3("Surface", Surface_methods, module_Surface_doc); /* mod name, table ptr */
|
||||
Base::Console().Log("Loading Surface module... done\n");
|
||||
|
||||
// Add types to module
|
||||
Surface::Filling ::init();
|
||||
Surface::Sewing ::init();
|
||||
Surface::Cut ::init();
|
||||
Surface::BezSurf ::init();
|
||||
Surface::BSplineSurf ::init();
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
38
src/Mod/Surface/App/AppSurfacePy.cpp
Normal file
38
src/Mod/Surface/App/AppSurfacePy.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2014 Nathan Miller Nathan.A.Mill[at]gmail.com *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* 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 Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
#endif
|
||||
|
||||
#include <Python.h>
|
||||
|
||||
#include <Base/Console.h>
|
||||
#include <Base/PyObjectBase.h>
|
||||
#include <Base/Exception.h>
|
||||
|
||||
|
||||
/* registration table */
|
||||
struct PyMethodDef Surface_methods[] = {
|
||||
{NULL, NULL} /* end of table marker */
|
||||
};
|
||||
51
src/Mod/Surface/App/CMakeLists.txt
Normal file
51
src/Mod/Surface/App/CMakeLists.txt
Normal file
@@ -0,0 +1,51 @@
|
||||
if(MSVC)
|
||||
add_definitions(-DHAVE_ACOSH -DHAVE_ASINH -DHAVE_ATANH)
|
||||
else(MSVC)
|
||||
add_definitions(-DHAVE_LIMITS_H -DHAVE_CONFIG_H)
|
||||
endif(MSVC)
|
||||
|
||||
include_directories(
|
||||
${Boost_INCLUDE_DIRS}
|
||||
${OCC_INCLUDE_DIR}
|
||||
${PYTHON_INCLUDE_PATH}
|
||||
${ZLIB_INCLUDE_DIR}
|
||||
${XERCESC_INCLUDE_DIR}
|
||||
${QT_QTCORE_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
set(Surface_LIBS
|
||||
FreeCADApp
|
||||
Part
|
||||
)
|
||||
|
||||
SET(Surface_SRCS
|
||||
AppSurface.cpp
|
||||
AppSurfacePy.cpp
|
||||
PreCompiled.cpp
|
||||
PreCompiled.h
|
||||
FeatureFilling.h
|
||||
FeatureFilling.cpp
|
||||
FeatureSewing.h
|
||||
FeatureSewing.cpp
|
||||
FeatureCut.h
|
||||
FeatureCut.cpp
|
||||
FeatureBezSurf.h
|
||||
FeatureBezSurf.cpp
|
||||
FeatureBSplineSurf.h
|
||||
FeatureBSplineSurf.cpp
|
||||
)
|
||||
|
||||
link_directories(${OCC_LIBRARY_DIR})
|
||||
add_library(Surface SHARED ${Surface_SRCS})
|
||||
target_link_libraries(Surface ${Surface_LIBS})
|
||||
|
||||
|
||||
fc_target_copy_resource(Surface
|
||||
${CMAKE_SOURCE_DIR}/src/Mod/Surface
|
||||
${CMAKE_BINARY_DIR}/Mod/Surface
|
||||
Init.py)
|
||||
|
||||
SET_BIN_DIR(Surface Surface /Mod/Surface)
|
||||
SET_PYTHON_PREFIX_SUFFIX(Surface)
|
||||
|
||||
install(TARGETS Surface DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
234
src/Mod/Surface/App/FeatureBSplineSurf.cpp
Normal file
234
src/Mod/Surface/App/FeatureBSplineSurf.cpp
Normal file
@@ -0,0 +1,234 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2014 Nathan Miller <Nathan.A.Mill[at]gmail.com> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* 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 Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
#include <BRepBuilderAPI_MakeFace.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopoDS_Face.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <TopoDS_Wire.hxx>
|
||||
#include <Geom_BSplineCurve.hxx>
|
||||
#include <Precision.hxx>
|
||||
#endif
|
||||
|
||||
#include "FeatureBSplineSurf.h"
|
||||
#include <GeomFill.hxx>
|
||||
#include <GeomFill_BSplineCurves.hxx>
|
||||
#include <ShapeFix_Wire.hxx>
|
||||
#include <ShapeExtend_WireData.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <BRepBuilderAPI_MakeFace.hxx>
|
||||
#include <BRepBuilderAPI_MakeWire.hxx>
|
||||
#include <Base/Tools.h>
|
||||
#include <Base/Exception.h>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
|
||||
using namespace Surface;
|
||||
|
||||
PROPERTY_SOURCE(Surface::BSplineSurf, Part::Feature)
|
||||
|
||||
//Initial values
|
||||
|
||||
BSplineSurf::BSplineSurf()
|
||||
{
|
||||
ADD_PROPERTY(aBSplineList,(0,"Geom_BSplineCurve"));
|
||||
ADD_PROPERTY(filltype,(1));
|
||||
|
||||
}
|
||||
|
||||
//Structures
|
||||
|
||||
struct crvs{
|
||||
|
||||
Handle_Geom_BSplineCurve C1;
|
||||
Handle_Geom_BSplineCurve C2;
|
||||
Handle_Geom_BSplineCurve C3;
|
||||
Handle_Geom_BSplineCurve C4;
|
||||
|
||||
};
|
||||
|
||||
//Functions
|
||||
|
||||
void getCurves(GeomFill_BSplineCurves& aBuilder,TopoDS_Wire& aWire, const App::PropertyLinkSubList& anEdge, GeomFill_FillingStyle fstyle);
|
||||
//bool orderCurves(crvs& Cs, int size);
|
||||
|
||||
//Check if any components of the surface have been modified
|
||||
|
||||
short BSplineSurf::mustExecute() const
|
||||
{
|
||||
if (aBSplineList.isTouched() ||
|
||||
filltype.isTouched())
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
App::DocumentObjectExecReturn *BSplineSurf::execute(void)
|
||||
{
|
||||
|
||||
//Set Variables
|
||||
|
||||
int ftype = filltype.getValue();
|
||||
|
||||
//Begin Construction
|
||||
try{
|
||||
|
||||
//Identify filling style
|
||||
|
||||
GeomFill_FillingStyle fstyle;
|
||||
|
||||
if(ftype==1){fstyle = GeomFill_StretchStyle;}
|
||||
else if(ftype==2){fstyle = GeomFill_CoonsStyle;}
|
||||
else if(ftype==3){fstyle = GeomFill_CurvedStyle;}
|
||||
else{return new App::DocumentObjectExecReturn("Filling style must be 1 (Stretch), 2 (Coons), or 3 (Curved).");}
|
||||
|
||||
//Create BSpline Surface
|
||||
|
||||
GeomFill_BSplineCurves aSurfBuilder; //Create Surface Builder
|
||||
// BRepBuilderAPI_MakeWire aWireBuilder; //Create Wire Builder
|
||||
TopoDS_Wire aWire; //Create empty wire
|
||||
|
||||
//Get BSpline Curves from edges and initialize the builder
|
||||
|
||||
printf("Entering getCurves\n");
|
||||
getCurves(aSurfBuilder,aWire,aBSplineList,fstyle);
|
||||
|
||||
//Create the surface
|
||||
printf("Creating the Surface\n");
|
||||
const Handle_Geom_BSplineSurface aSurface = aSurfBuilder.Surface();
|
||||
|
||||
printf("Creating the Face\n");
|
||||
BRepBuilderAPI_MakeFace aFaceBuilder(aSurface,aWire,Standard_True); //Create Face Builder
|
||||
// Standard_Real u0 = 0.;
|
||||
// Standard_Real u1 = 2.;
|
||||
// Standard_Real v0 = 0.;
|
||||
// Standard_Real v1 = 2.;
|
||||
// aFaceBuilder.Init(aSurface,u0,u1,v0,v1,Precision::Confusion());
|
||||
|
||||
printf("Returning the Face\n");
|
||||
TopoDS_Face aFace = aFaceBuilder.Face(); //Returned Face
|
||||
if(!aFaceBuilder.IsDone()){return new App::DocumentObjectExecReturn("Face unable to be constructed");}
|
||||
|
||||
if (aFace.IsNull()){
|
||||
return new App::DocumentObjectExecReturn("Resulting Face is null");
|
||||
}
|
||||
this->Shape.setValue(aFace);
|
||||
|
||||
return App::DocumentObject::StdReturn;
|
||||
|
||||
} //End Try
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
return new App::DocumentObjectExecReturn(e->GetMessageString());
|
||||
} //End Catch
|
||||
|
||||
} //End execute
|
||||
|
||||
void getCurves(GeomFill_BSplineCurves& aBuilder,TopoDS_Wire& aWire, const App::PropertyLinkSubList& anEdge, GeomFill_FillingStyle fstyle){
|
||||
//void getCurves(TopoDS_Wire& aWire, const App::PropertyLinkSubList& anEdge){
|
||||
|
||||
crvs bcrv;
|
||||
|
||||
Standard_Real u0 = 0.;
|
||||
Standard_Real u1 = 1.;
|
||||
|
||||
Handle(ShapeFix_Wire) aShFW = new ShapeFix_Wire;
|
||||
Handle(ShapeExtend_WireData) aWD = new ShapeExtend_WireData;
|
||||
|
||||
if(anEdge.getSize()>4){Standard_Failure::Raise("Only 2-4 continuous BSpline Curves are allowed");return;}
|
||||
if(anEdge.getSize()<2){Standard_Failure::Raise("Only 2-4 continuous BSpline Curves are allowed");return;}
|
||||
|
||||
for(int i=0; i<anEdge.getSize(); i++){
|
||||
|
||||
Part::TopoShape ts; //Curve TopoShape
|
||||
TopoDS_Shape sub; //Curve TopoDS_Shape
|
||||
TopoDS_Edge etmp; //Curve TopoDS_Edge
|
||||
|
||||
|
||||
//Get Edge
|
||||
App::PropertyLinkSubList::SubSet set = anEdge[i];
|
||||
|
||||
if(set.obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
|
||||
|
||||
ts = static_cast<Part::Feature*>(set.obj)->Shape.getShape();
|
||||
|
||||
//we want only the subshape which is linked
|
||||
sub = ts.getSubShape(set.sub);
|
||||
|
||||
if(sub.ShapeType() == TopAbs_EDGE) {etmp = TopoDS::Edge(sub);} //Check Shape type and assign edge
|
||||
else{Standard_Failure::Raise("Curves must be type TopoDS_Edge");return;} //Raise exception
|
||||
|
||||
aWD->Add(etmp);
|
||||
|
||||
}
|
||||
|
||||
else{Standard_Failure::Raise("Curve not from Part::Feature");return;}
|
||||
|
||||
}
|
||||
|
||||
//Reorder the curves and fix the wire if required
|
||||
|
||||
aShFW->Load(aWD); //Load in the wire
|
||||
aShFW->FixReorder(); //Fix the order of the edges if required
|
||||
aShFW->ClosedWireMode() = Standard_True; //Enables closed wire mode
|
||||
aShFW->FixConnected(); //Fix connection between wires
|
||||
aShFW->FixSelfIntersection(); //Fix Self Intersection
|
||||
aShFW->Perform(); //Perform the fixes
|
||||
|
||||
aWire = aShFW->Wire(); //Healed Wire
|
||||
|
||||
if(aWire.IsNull()){Standard_Failure::Raise("Wire unable to be constructed");return;}
|
||||
|
||||
//Create BSpline Surface
|
||||
|
||||
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 = hedge.Location();
|
||||
Handle_Geom_Curve c_geom = BRep_Tool::Curve(hedge,heloc,u0,u1); //The geometric curve
|
||||
Handle_Geom_BSplineCurve b_geom = Handle_Geom_BSplineCurve::DownCast(c_geom); //Try to get BSpline curve
|
||||
|
||||
if (!b_geom.IsNull()) {
|
||||
//Store Underlying Geometry
|
||||
if(it==0){bcrv.C1 = b_geom;}
|
||||
else if(it==1){bcrv.C2 = b_geom;}
|
||||
else if(it==2){bcrv.C3 = b_geom;}
|
||||
else if(it==3){bcrv.C4 = b_geom;}
|
||||
|
||||
}
|
||||
else {
|
||||
Standard_Failure::Raise("Curve not a BSpline Curve");
|
||||
return;
|
||||
}
|
||||
|
||||
it++;
|
||||
}
|
||||
|
||||
int ncrv = anEdge.getSize();
|
||||
|
||||
if(ncrv==2){aBuilder.Init(bcrv.C1,bcrv.C2,fstyle);}
|
||||
else if(ncrv==3){aBuilder.Init(bcrv.C1,bcrv.C2,bcrv.C3,fstyle);}
|
||||
else if(ncrv==4){aBuilder.Init(bcrv.C1,bcrv.C2,bcrv.C3,bcrv.C4,fstyle);}
|
||||
|
||||
return;
|
||||
}
|
||||
54
src/Mod/Surface/App/FeatureBSplineSurf.h
Normal file
54
src/Mod/Surface/App/FeatureBSplineSurf.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2014 Nathan Miller <Nathan.A.Mill[at]gmail.com> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* 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 Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef SURFACE_FEATUREBSPLINESURF_H
|
||||
#define SURFACE_FEATUREBSPLINESURF_H
|
||||
|
||||
#include <App/PropertyStandard.h>
|
||||
#include <App/PropertyUnits.h>
|
||||
#include <App/PropertyLinks.h>
|
||||
#include "Mod/Part/App/PartFeature.h"
|
||||
|
||||
namespace Surface
|
||||
{
|
||||
|
||||
class SurfaceExport BSplineSurf : public Part::Feature
|
||||
{
|
||||
PROPERTY_HEADER(Surface::BSplineSurf);
|
||||
|
||||
public:
|
||||
BSplineSurf();
|
||||
|
||||
App::PropertyLinkSubList aBSplineList; //BSpline curves to be turned into a face (2-4 curves allowed).
|
||||
App::PropertyInteger filltype; //Fill method (1, 2, or 3 for Stretch, Coons, and Curved)
|
||||
|
||||
// recalculate the feature
|
||||
App::DocumentObjectExecReturn *execute(void);
|
||||
short mustExecute() const;
|
||||
/// returns the type name of the view provider
|
||||
// const char* getViewProviderName(void) const {
|
||||
// return "PartGui::ViewProviderCut";
|
||||
// }
|
||||
|
||||
};
|
||||
}//Namespace Surface
|
||||
#endif
|
||||
232
src/Mod/Surface/App/FeatureBezSurf.cpp
Normal file
232
src/Mod/Surface/App/FeatureBezSurf.cpp
Normal file
@@ -0,0 +1,232 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2014 Nathan Miller <Nathan.A.Mill[at]gmail.com> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* 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 Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
#include <BRepBuilderAPI_MakeFace.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopoDS_Face.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <TopoDS_Wire.hxx>
|
||||
#include <Geom_BezierCurve.hxx>
|
||||
#include <Precision.hxx>
|
||||
#endif
|
||||
|
||||
#include "FeatureBezSurf.h"
|
||||
#include <GeomFill.hxx>
|
||||
#include <GeomFill_BezierCurves.hxx>
|
||||
#include <ShapeFix_Wire.hxx>
|
||||
#include <ShapeExtend_WireData.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <BRepBuilderAPI_MakeFace.hxx>
|
||||
#include <BRepBuilderAPI_MakeWire.hxx>
|
||||
#include <Base/Tools.h>
|
||||
#include <Base/Exception.h>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
|
||||
using namespace Surface;
|
||||
|
||||
PROPERTY_SOURCE(Surface::BezSurf, Part::Feature)
|
||||
|
||||
//Initial values
|
||||
|
||||
BezSurf::BezSurf()
|
||||
{
|
||||
ADD_PROPERTY(aBezList,(0,"Geom_BezierCurve"));
|
||||
ADD_PROPERTY(filltype,(1));
|
||||
|
||||
}
|
||||
|
||||
//Structures
|
||||
|
||||
struct crvs{
|
||||
|
||||
Handle_Geom_BezierCurve C1;
|
||||
Handle_Geom_BezierCurve C2;
|
||||
Handle_Geom_BezierCurve C3;
|
||||
Handle_Geom_BezierCurve C4;
|
||||
|
||||
};
|
||||
|
||||
//Functions
|
||||
|
||||
void getCurves(GeomFill_BezierCurves& aBuilder,TopoDS_Wire& aWire, const App::PropertyLinkSubList& anEdge, GeomFill_FillingStyle fstyle);
|
||||
//bool orderCurves(crvs& Cs, int size);
|
||||
|
||||
//Check if any components of the surface have been modified
|
||||
|
||||
short BezSurf::mustExecute() const
|
||||
{
|
||||
if (aBezList.isTouched() ||
|
||||
filltype.isTouched())
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
App::DocumentObjectExecReturn *BezSurf::execute(void)
|
||||
{
|
||||
|
||||
//Set Variables
|
||||
|
||||
int ftype = filltype.getValue();
|
||||
|
||||
//Begin Construction
|
||||
try{
|
||||
|
||||
//Identify filling style
|
||||
|
||||
GeomFill_FillingStyle fstyle;
|
||||
|
||||
if(ftype==1){fstyle = GeomFill_StretchStyle;}
|
||||
else if(ftype==2){fstyle = GeomFill_CoonsStyle;}
|
||||
else if(ftype==3){fstyle = GeomFill_CurvedStyle;}
|
||||
else{return new App::DocumentObjectExecReturn("Filling style must be 1 (Stretch), 2 (Coons), or 3 (Curved).");}
|
||||
|
||||
//Create Bezier Surface
|
||||
|
||||
GeomFill_BezierCurves aSurfBuilder; //Create Surface Builder
|
||||
// BRepBuilderAPI_MakeWire aWireBuilder; //Create Wire Builder
|
||||
TopoDS_Wire aWire; //Create empty wire
|
||||
|
||||
//Get Bezier Curves from edges and initialize the builder
|
||||
|
||||
getCurves(aSurfBuilder,aWire,aBezList,fstyle);
|
||||
|
||||
//Create the surface
|
||||
|
||||
const Handle_Geom_BezierSurface aSurface = aSurfBuilder.Surface();
|
||||
|
||||
BRepBuilderAPI_MakeFace aFaceBuilder;//(aSurface,aWire,Standard_True); //Create Face Builder
|
||||
Standard_Real u0 = 0.;
|
||||
Standard_Real u1 = 1.;
|
||||
Standard_Real v0 = 0.;
|
||||
Standard_Real v1 = 1.;
|
||||
aFaceBuilder.Init(aSurface,u0,u1,v0,v1,Precision::Confusion());
|
||||
|
||||
TopoDS_Face aFace = aFaceBuilder.Face(); //Returned Face
|
||||
if(!aFaceBuilder.IsDone()){return new App::DocumentObjectExecReturn("Face unable to be constructed");}
|
||||
|
||||
if (aFace.IsNull()){
|
||||
return new App::DocumentObjectExecReturn("Resulting Face is null");
|
||||
}
|
||||
this->Shape.setValue(aFace);
|
||||
|
||||
return App::DocumentObject::StdReturn;
|
||||
|
||||
} //End Try
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
return new App::DocumentObjectExecReturn(e->GetMessageString());
|
||||
} //End Catch
|
||||
|
||||
} //End execute
|
||||
|
||||
void getCurves(GeomFill_BezierCurves& aBuilder,TopoDS_Wire& aWire, const App::PropertyLinkSubList& anEdge, GeomFill_FillingStyle fstyle){
|
||||
//void getCurves(TopoDS_Wire& aWire, const App::PropertyLinkSubList& anEdge){
|
||||
|
||||
crvs bcrv;
|
||||
|
||||
Standard_Real u0 = 0.;
|
||||
Standard_Real u1 = 1.;
|
||||
|
||||
Handle(ShapeFix_Wire) aShFW = new ShapeFix_Wire;
|
||||
Handle(ShapeExtend_WireData) aWD = new ShapeExtend_WireData;
|
||||
|
||||
if(anEdge.getSize()>4){Standard_Failure::Raise("Only 2-4 continuous Bezier Curves are allowed");return;}
|
||||
if(anEdge.getSize()<2){Standard_Failure::Raise("Only 2-4 continuous Bezier Curves are allowed");return;}
|
||||
|
||||
for(int i=0; i<anEdge.getSize(); i++){
|
||||
|
||||
Part::TopoShape ts; //Curve TopoShape
|
||||
TopoDS_Shape sub; //Curve TopoDS_Shape
|
||||
TopoDS_Edge etmp; //Curve TopoDS_Edge
|
||||
|
||||
|
||||
//Get Edge
|
||||
App::PropertyLinkSubList::SubSet set = anEdge[i];
|
||||
|
||||
if(set.obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
|
||||
|
||||
ts = static_cast<Part::Feature*>(set.obj)->Shape.getShape();
|
||||
|
||||
//we want only the subshape which is linked
|
||||
sub = ts.getSubShape(set.sub);
|
||||
|
||||
if(sub.ShapeType() == TopAbs_EDGE) {etmp = TopoDS::Edge(sub);} //Check Shape type and assign edge
|
||||
else{Standard_Failure::Raise("Curves must be type TopoDS_Edge");return;} //Raise exception
|
||||
|
||||
aWD->Add(etmp);
|
||||
|
||||
}
|
||||
|
||||
else{Standard_Failure::Raise("Curve not from Part::Feature");return;}
|
||||
|
||||
}
|
||||
|
||||
//Reorder the curves and fix the wire if required
|
||||
|
||||
aShFW->Load(aWD); //Load in the wire
|
||||
aShFW->FixReorder(); //Fix the order of the edges if required
|
||||
aShFW->ClosedWireMode() = Standard_True; //Enables closed wire mode
|
||||
aShFW->FixConnected(); //Fix connection between wires
|
||||
aShFW->FixSelfIntersection(); //Fix Self Intersection
|
||||
aShFW->Perform(); //Perform the fixes
|
||||
|
||||
aWire = aShFW->Wire(); //Healed Wire
|
||||
|
||||
if(aWire.IsNull()){Standard_Failure::Raise("Wire unable to be constructed");return;}
|
||||
|
||||
//Create Bezier Surface
|
||||
|
||||
TopExp_Explorer anExp (aWire, TopAbs_EDGE);
|
||||
int it = 0;
|
||||
for (; anExp.More(); anExp.Next()) {
|
||||
printf("it: %i",it);
|
||||
const TopoDS_Edge hedge = TopoDS::Edge (anExp.Current());
|
||||
TopLoc_Location heloc = hedge.Location();
|
||||
Handle_Geom_Curve c_geom = BRep_Tool::Curve(hedge,heloc,u0,u1); //The geometric curve
|
||||
Handle_Geom_BezierCurve b_geom = Handle_Geom_BezierCurve::DownCast(c_geom); //Try to get Bezier curve
|
||||
|
||||
if (!b_geom.IsNull()) {
|
||||
//Store Underlying Geometry
|
||||
if(it==0){bcrv.C1 = b_geom;}
|
||||
else if(it==1){bcrv.C2 = b_geom;}
|
||||
else if(it==2){bcrv.C3 = b_geom;}
|
||||
else if(it==3){bcrv.C4 = b_geom;}
|
||||
|
||||
}
|
||||
else {
|
||||
Standard_Failure::Raise("Curve not a Bezier Curve");
|
||||
return;
|
||||
}
|
||||
|
||||
it++;
|
||||
}
|
||||
|
||||
int ncrv = anEdge.getSize();
|
||||
|
||||
if(ncrv==2){aBuilder.Init(bcrv.C1,bcrv.C2,fstyle);}
|
||||
else if(ncrv==3){aBuilder.Init(bcrv.C1,bcrv.C2,bcrv.C3,fstyle);}
|
||||
else if(ncrv==4){aBuilder.Init(bcrv.C1,bcrv.C2,bcrv.C3,bcrv.C4,fstyle);}
|
||||
|
||||
return;
|
||||
}
|
||||
54
src/Mod/Surface/App/FeatureBezSurf.h
Normal file
54
src/Mod/Surface/App/FeatureBezSurf.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2014 Nathan Miller <Nathan.A.Mill[at]gmail.com> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* 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 Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef SURFACE_FEATUREBEZSURF_H
|
||||
#define SURFACE_FEATUREBEZSURF_H
|
||||
|
||||
#include <App/PropertyStandard.h>
|
||||
#include <App/PropertyUnits.h>
|
||||
#include <App/PropertyLinks.h>
|
||||
#include "Mod/Part/App/PartFeature.h"
|
||||
|
||||
namespace Surface
|
||||
{
|
||||
|
||||
class SurfaceExport BezSurf : public Part::Feature
|
||||
{
|
||||
PROPERTY_HEADER(Surface::BezSurf);
|
||||
|
||||
public:
|
||||
BezSurf();
|
||||
|
||||
App::PropertyLinkSubList aBezList; //Bezier curves to be turned into a face (2-4 curves allowed).
|
||||
App::PropertyInteger filltype; //Fill method (1, 2, or 3 for Stretch, Coons, and Curved)
|
||||
|
||||
// recalculate the feature
|
||||
App::DocumentObjectExecReturn *execute(void);
|
||||
short mustExecute() const;
|
||||
/// returns the type name of the view provider
|
||||
// const char* getViewProviderName(void) const {
|
||||
// return "PartGui::ViewProviderCut";
|
||||
// }
|
||||
|
||||
};
|
||||
}//Namespace Surface
|
||||
#endif
|
||||
119
src/Mod/Surface/App/FeatureCut.cpp
Normal file
119
src/Mod/Surface/App/FeatureCut.cpp
Normal file
@@ -0,0 +1,119 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2014 Nathan Miller <Nathan.A.Mill[at]gmail.com> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* 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 Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
#include <BRepBuilderAPI_MakeFace.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <Precision.hxx>
|
||||
#endif
|
||||
|
||||
#include "FeatureCut.h"
|
||||
#include <BRepAlgoAPI_Cut.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
#include <TopoDS_Builder.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <Base/Tools.h>
|
||||
#include <Base/Exception.h>
|
||||
|
||||
using namespace Surface;
|
||||
|
||||
PROPERTY_SOURCE(Surface::Cut, Part::Feature)
|
||||
|
||||
//Initial values
|
||||
|
||||
Cut::Cut()
|
||||
{
|
||||
ADD_PROPERTY(aShapeList,(0,"TopoDS_Shape"));
|
||||
|
||||
}
|
||||
|
||||
//Check if any components of the surface have been modified
|
||||
|
||||
short Cut::mustExecute() const
|
||||
{
|
||||
if (aShapeList.isTouched())
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
App::DocumentObjectExecReturn *Cut::execute(void)
|
||||
{
|
||||
|
||||
//Perform error checking
|
||||
|
||||
bool res;
|
||||
|
||||
//Begin Construction
|
||||
try{
|
||||
|
||||
if((aShapeList.getSize()>2) || (aShapeList.getSize()<2)){
|
||||
return new App::DocumentObjectExecReturn("Two shapes must be entered at a time for a cut operation");
|
||||
}
|
||||
|
||||
//Initialize variables for first toposhape from document object
|
||||
Part::TopoShape ts1;
|
||||
TopoDS_Shape sub1;
|
||||
App::PropertyLinkSubList::SubSet set1 = aShapeList[0];
|
||||
|
||||
//Initialize variables for second toposhape from document object
|
||||
Part::TopoShape ts2;
|
||||
TopoDS_Shape sub2;
|
||||
App::PropertyLinkSubList::SubSet set2 = aShapeList[1];
|
||||
|
||||
//Get first toposhape
|
||||
printf("Get first toposhape\n");
|
||||
if(set1.obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
|
||||
|
||||
ts1 = static_cast<Part::Feature*>(set1.obj)->Shape.getShape(); //Part::TopoShape 1
|
||||
|
||||
}
|
||||
else{return new App::DocumentObjectExecReturn("Shape1 not from Part::Feature");}
|
||||
|
||||
//Get second toposhape
|
||||
printf("Get second toposhape\n");
|
||||
if(set2.obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
|
||||
|
||||
ts2 = static_cast<Part::Feature*>(set2.obj)->Shape.getShape();
|
||||
|
||||
}
|
||||
else{return new App::DocumentObjectExecReturn("Shape2 not from Part::Feature");}
|
||||
|
||||
//Cut Shape1 by Shape2
|
||||
TopoDS_Shape aCutShape;
|
||||
aCutShape = ts1.cut(ts2._Shape);
|
||||
|
||||
//Check if resulting shell is null
|
||||
if (aCutShape.IsNull()){
|
||||
return new App::DocumentObjectExecReturn("Resulting shape is null");
|
||||
}
|
||||
this->Shape.setValue(aCutShape);
|
||||
|
||||
} //End Try
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
return new App::DocumentObjectExecReturn(e->GetMessageString());
|
||||
} //End Catch
|
||||
|
||||
} //End execute
|
||||
53
src/Mod/Surface/App/FeatureCut.h
Normal file
53
src/Mod/Surface/App/FeatureCut.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2014 Nathan Miller <Nathan.A.Mill[at]gmail.com> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* 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 Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef SURFACE_FEATURECUT_H
|
||||
#define SURFACE_FEATURECUT_H
|
||||
|
||||
#include <App/PropertyStandard.h>
|
||||
#include <App/PropertyUnits.h>
|
||||
#include <App/PropertyLinks.h>
|
||||
#include "Mod/Part/App/PartFeature.h"
|
||||
|
||||
namespace Surface
|
||||
{
|
||||
|
||||
class SurfaceExport Cut : public Part::Feature
|
||||
{
|
||||
PROPERTY_HEADER(Surface::Cut);
|
||||
|
||||
public:
|
||||
Cut();
|
||||
|
||||
App::PropertyLinkSubList aShapeList; //Shapes to be cut.
|
||||
|
||||
// recalculate the feature
|
||||
App::DocumentObjectExecReturn *execute(void);
|
||||
short mustExecute() const;
|
||||
/// returns the type name of the view provider
|
||||
// const char* getViewProviderName(void) const {
|
||||
// return "SurfaceGui::ViewProviderCut";
|
||||
// }
|
||||
|
||||
};
|
||||
}//Namespace Surface
|
||||
#endif
|
||||
461
src/Mod/Surface/App/FeatureFilling.cpp
Normal file
461
src/Mod/Surface/App/FeatureFilling.cpp
Normal file
@@ -0,0 +1,461 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2014 Nathan Miller <Nathan.A.Mill[at]gmail.com> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* 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 Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
#include <BRepBuilderAPI_MakeFace.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <TopoDS_Vertex.hxx>
|
||||
#include <Precision.hxx>
|
||||
#endif
|
||||
|
||||
#include "FeatureFilling.h"
|
||||
#include <BRepFill_Filling.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <Base/Tools.h>
|
||||
#include <Base/Exception.h>
|
||||
#include <string.h>
|
||||
|
||||
using namespace Surface;
|
||||
|
||||
PROPERTY_SOURCE(Surface::Filling, Part::Feature)
|
||||
|
||||
//Initial values
|
||||
|
||||
Filling::Filling()
|
||||
{
|
||||
ADD_PROPERTY(Border,(0,"TopoDS_Edge"));
|
||||
|
||||
ADD_PROPERTY(Curves,(0,"TopoDS_Edge"));
|
||||
|
||||
ADD_PROPERTY(BFaces,(0,"TopoDS_Face"));
|
||||
ADD_PROPERTY(orderB,(-1));
|
||||
ADD_PROPERTY(CFaces,(0,"TopoDS_Face"));
|
||||
ADD_PROPERTY(orderC,(-1));
|
||||
|
||||
ADD_PROPERTY(Points,(0,"TopoDS_Vertex"));
|
||||
|
||||
ADD_PROPERTY(initFace,(0,"TopoDS_Face"));
|
||||
|
||||
ADD_PROPERTY(Degree,(3));
|
||||
ADD_PROPERTY(NbPtsOnCur,(3));
|
||||
ADD_PROPERTY(NbIter,(2));
|
||||
ADD_PROPERTY(Anisotropie,(false));
|
||||
ADD_PROPERTY(Tol2d,(0.00001));
|
||||
ADD_PROPERTY(Tol3d,(0.0001));
|
||||
ADD_PROPERTY(TolAng,(0.001));
|
||||
ADD_PROPERTY(TolCurv,(0.01));
|
||||
ADD_PROPERTY(MaxDeg,(8));
|
||||
ADD_PROPERTY(MaxSegments,(10000));
|
||||
}
|
||||
|
||||
//Define Functions
|
||||
|
||||
void appconstr_crv(BRepFill_Filling& builder,const App::PropertyLinkSubList& anEdge, Standard_Boolean bnd);
|
||||
void appconstr_bface(BRepFill_Filling& builder,const App::PropertyLinkSubList& aFace, const App::PropertyIntegerList& Order);
|
||||
void appconstr_crvface(BRepFill_Filling& builder, const App::PropertyLinkSubList& anEdge, const App::PropertyLinkSubList& aFace, const App::PropertyIntegerList& Order, Standard_Boolean bnd);
|
||||
void appconstr_pt(BRepFill_Filling& builder,const App::PropertyLinkSubList& aVertex);
|
||||
void appinitface(BRepFill_Filling& builder,const App::PropertyLinkSubList& aFace);
|
||||
|
||||
//Check if any components of the surface have been modified
|
||||
|
||||
short Filling::mustExecute() const
|
||||
{
|
||||
if (Border.isTouched() ||
|
||||
Curves.isTouched() ||
|
||||
BFaces.isTouched() ||
|
||||
orderB.isTouched() ||
|
||||
CFaces.isTouched() ||
|
||||
orderC.isTouched() ||
|
||||
Points.isTouched() ||
|
||||
initFace.isTouched() ||
|
||||
Degree.isTouched() ||
|
||||
NbPtsOnCur.isTouched() ||
|
||||
NbIter.isTouched() ||
|
||||
Anisotropie.isTouched() ||
|
||||
Tol2d.isTouched() ||
|
||||
Tol3d.isTouched() ||
|
||||
TolAng.isTouched() ||
|
||||
TolCurv.isTouched() ||
|
||||
MaxDeg.isTouched() ||
|
||||
MaxSegments.isTouched())
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
App::DocumentObjectExecReturn *Filling::execute(void)
|
||||
{
|
||||
|
||||
//Assign Variables
|
||||
|
||||
|
||||
|
||||
unsigned int Deg = Degree.getValue();
|
||||
unsigned int NPOC = NbPtsOnCur.getValue();
|
||||
unsigned int NI = NbIter.getValue();
|
||||
bool Anis = Anisotropie.getValue();
|
||||
double T2d = Tol2d.getValue();
|
||||
double T3d = Tol3d.getValue();
|
||||
double TG1 = TolAng.getValue();
|
||||
double TG2 = TolCurv.getValue();
|
||||
unsigned int Mdeg = MaxDeg.getValue();
|
||||
unsigned int Mseg = MaxSegments.getValue();
|
||||
|
||||
bool res;
|
||||
|
||||
//Perform error checking
|
||||
|
||||
|
||||
//Begin Construction
|
||||
try{
|
||||
|
||||
//Generate Builder with Algorithm Variables
|
||||
|
||||
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
|
||||
if(Border.getSize()>0){appconstr_crvface(builder, Border, BFaces, orderB, Standard_True);}
|
||||
|
||||
//Assign Additional Curves if available
|
||||
|
||||
if(Curves.getSize()>0){appconstr_crvface(builder, Curves, CFaces, orderC, Standard_False);}
|
||||
|
||||
/* //Assign Faces
|
||||
|
||||
if(BFaces.getSize()>0){appconstr_bface(builder, BFaces, orderBFaces);}
|
||||
*/
|
||||
//Assign Point Constraints
|
||||
|
||||
if(Points.getSize()>0){appconstr_pt(builder,Points);}
|
||||
|
||||
//Assign Initial Face
|
||||
|
||||
if(initFace.getSize()>0){appinitface(builder,initFace);}
|
||||
|
||||
printf("Building...\n");
|
||||
|
||||
//Build the face
|
||||
builder.Build();
|
||||
if (!builder.IsDone()){Standard_Failure::Raise("Failed to create a face from constraints");}
|
||||
|
||||
printf("Build Complete\n");
|
||||
|
||||
//Return the face
|
||||
TopoDS_Face aFace = builder.Face();
|
||||
|
||||
if (aFace.IsNull()){
|
||||
return new App::DocumentObjectExecReturn("Resulting shape is null");
|
||||
}
|
||||
this->Shape.setValue(aFace);
|
||||
|
||||
return App::DocumentObject::StdReturn;
|
||||
|
||||
} //End Try
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
return new App::DocumentObjectExecReturn(e->GetMessageString());
|
||||
} //End Catch
|
||||
|
||||
} //End execute
|
||||
/*
|
||||
void appconstr_crv(BRepFill_Filling& builder,const App::PropertyLinkSubList& anEdge, Standard_Boolean bnd){
|
||||
|
||||
printf("Inside appconstr_crv\n");
|
||||
|
||||
int res;
|
||||
|
||||
printf("Entering for loop\n");
|
||||
|
||||
for(int i=0; i<anEdge.getSize(); i++) {
|
||||
|
||||
printf("Processing curve %i\n",i);
|
||||
|
||||
Part::TopoShape ts;
|
||||
// Part::TopoShape sub;
|
||||
TopoDS_Shape sub;
|
||||
TopoDS_Edge etmp;
|
||||
|
||||
//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
|
||||
|
||||
// printf("Pre try\n");
|
||||
//
|
||||
// try{anEdge[i].obj;}
|
||||
// catch(...){
|
||||
// Standard_Failure::Raise("Check Boundary or Curve Definitions.\nShould be of form [(App.ActiveDocument.object, 'Edge Name'),...");
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// printf("Made it past try\n");
|
||||
//
|
||||
App::PropertyLinkSubList::SubSet set = anEdge[i];
|
||||
|
||||
printf("Past set = anEdge[i]\n");
|
||||
|
||||
//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);
|
||||
|
||||
if(sub.ShapeType() == TopAbs_EDGE) {etmp = TopoDS::Edge(sub);} //Check Shape type and assign edge
|
||||
else{Standard_Failure::Raise("Curves must be type TopoDS_Edge");return;} //Raise exception
|
||||
|
||||
}
|
||||
|
||||
else{Standard_Failure::Raise("Boundary or Curve not from Part::Feature");return;}
|
||||
|
||||
res = builder.Add(etmp,GeomAbs_C0,bnd);
|
||||
|
||||
printf("Result of builder.Add: %i\n",res);
|
||||
|
||||
}
|
||||
}
|
||||
*/
|
||||
/*
|
||||
void appconstr_bface(BRepFill_Filling& builder,const App::PropertyLinkSubList& aFace, const App::PropertyIntegerList& Order){
|
||||
|
||||
int res;
|
||||
|
||||
GeomAbs_Shape ordtmp;
|
||||
|
||||
std::vector<long int>::const_iterator bc = Order.getValues().begin(); //Get the order values
|
||||
|
||||
for(int i=0; i<aFace.getSize(); i++){
|
||||
|
||||
Part::TopoShape ts;
|
||||
TopoDS_Shape sub;
|
||||
TopoDS_Face ftmp;
|
||||
|
||||
App::PropertyLinkSubList::SubSet set = aFace[i];
|
||||
|
||||
if(set.obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
|
||||
|
||||
ts = static_cast<Part::Feature*>(set.obj)->Shape.getShape();
|
||||
|
||||
sub = ts.getSubShape(set.sub);
|
||||
|
||||
if(sub.ShapeType() == TopAbs_FACE) {ftmp = TopoDS::Face(sub);} //Check Shape type and assign edge
|
||||
else{Standard_Failure::Raise("Faces must be type TopoDS_Face");} //Raise exception
|
||||
|
||||
}
|
||||
|
||||
else{Standard_Failure::Raise("Face not from Part::Feature");}
|
||||
|
||||
//PropertyEnumerateList doesn't exist yet. Fix when implemented
|
||||
|
||||
if(*bc==0){ordtmp = GeomAbs_C0;}
|
||||
else if(*bc==1){ordtmp = GeomAbs_G1;}
|
||||
else if(*bc==2){ordtmp = GeomAbs_G2;}
|
||||
else{Standard_Failure::Raise("Continuity constraint must be 0, 1 or 2 for C0, G1, and G2.");return;}
|
||||
|
||||
printf("*bc: %li\n",*bc);
|
||||
|
||||
res = builder.Add(ftmp,ordtmp);
|
||||
|
||||
printf("res: %i\n",res);
|
||||
|
||||
bc++;
|
||||
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
*/
|
||||
void appconstr_crvface(BRepFill_Filling& builder, const App::PropertyLinkSubList& anEdge, const App::PropertyLinkSubList& aFace, const App::PropertyIntegerList& Order, Standard_Boolean bnd){
|
||||
|
||||
int res;
|
||||
|
||||
GeomAbs_Shape ordtmp;
|
||||
|
||||
std::vector<long int>::const_iterator bc = Order.getValues().begin(); //Get the order values
|
||||
int fconit = 0;
|
||||
|
||||
for(int i=0; i<anEdge.getSize(); i++){
|
||||
|
||||
Part::TopoShape ts_edge;
|
||||
TopoDS_Shape sub_edge;
|
||||
|
||||
Part::TopoShape ts_face;
|
||||
TopoDS_Shape sub_face;
|
||||
|
||||
TopoDS_Edge etmp;
|
||||
TopoDS_Face ftmp;
|
||||
|
||||
//Get Edge
|
||||
|
||||
App::PropertyLinkSubList::SubSet set_edge = anEdge[i];
|
||||
|
||||
if(set_edge.obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
|
||||
|
||||
ts_edge = static_cast<Part::Feature*>(set_edge.obj)->Shape.getShape();
|
||||
|
||||
//we want only the subshape which is linked
|
||||
sub_edge = ts_edge.getSubShape(set_edge.sub);
|
||||
|
||||
if(sub_edge.ShapeType() == TopAbs_EDGE) {etmp = TopoDS::Edge(sub_edge);} //Check Shape type and assign edge
|
||||
else{Standard_Failure::Raise("Curves must be type TopoDS_Edge");return;} //Raise exception
|
||||
|
||||
}
|
||||
|
||||
else{Standard_Failure::Raise("Boundary or Curve not from Part::Feature");return;}
|
||||
|
||||
/*********************************/
|
||||
|
||||
//Get Order
|
||||
|
||||
//PropertyEnumerateList doesn't exist yet. Fix when implemented
|
||||
|
||||
if(*bc==0){ordtmp = GeomAbs_C0;}
|
||||
else if(*bc==1){ordtmp = GeomAbs_G1;}
|
||||
else if(*bc==2){ordtmp = GeomAbs_G2;}
|
||||
else{Standard_Failure::Raise("Continuity constraint must be 0, 1 or 2 for C0, G1, and G2.");return;}
|
||||
|
||||
/*********************************/
|
||||
|
||||
//Get Face if required
|
||||
|
||||
if(ordtmp==GeomAbs_C0){
|
||||
|
||||
res = builder.Add(etmp,ordtmp,bnd);
|
||||
|
||||
}
|
||||
|
||||
else{
|
||||
|
||||
// if(aFace.getSize()<anEdge.getSize()){
|
||||
// Standard_Failure::Raise("Faces must be defined (even as null) for all edges if G1 or G2 constraints are used.");
|
||||
// }
|
||||
|
||||
App::PropertyLinkSubList::SubSet set_face = aFace[fconit];
|
||||
|
||||
if(set_face.obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
|
||||
|
||||
ts_face = static_cast<Part::Feature*>(set_face.obj)->Shape.getShape();
|
||||
|
||||
sub_face = ts_face.getSubShape(set_face.sub);
|
||||
|
||||
if(sub_face.ShapeType() == TopAbs_FACE) {ftmp = TopoDS::Face(sub_face);} //Check Shape type and assign edge
|
||||
else{Standard_Failure::Raise("Faces must be type TopoDS_Face");} //Raise exception
|
||||
|
||||
}
|
||||
|
||||
else{Standard_Failure::Raise("Face not from Part::Feature");}
|
||||
|
||||
printf("*bc: %li\n",*bc);
|
||||
|
||||
res = builder.Add(etmp,ftmp,ordtmp,bnd);
|
||||
|
||||
fconit++;
|
||||
|
||||
}
|
||||
|
||||
printf("res: %i\n",res);
|
||||
|
||||
bc++;
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void appconstr_pt(BRepFill_Filling& builder,const App::PropertyLinkSubList& aVertex){
|
||||
|
||||
int res;
|
||||
|
||||
for(int i=0; i<aVertex.getSize(); i++) {
|
||||
|
||||
Part::TopoShape ts;
|
||||
// Part::TopoShape sub;
|
||||
TopoDS_Shape sub;
|
||||
TopoDS_Vertex vtmp;
|
||||
|
||||
//the subset has the documentobject and the element name which belongs to it,
|
||||
// in our case for example the cube object and the "Vertex1" string
|
||||
App::PropertyLinkSubList::SubSet set = aVertex[i];
|
||||
|
||||
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);
|
||||
|
||||
if(sub.ShapeType() == TopAbs_VERTEX) {vtmp = TopoDS::Vertex(sub);} //Check Shape type and assign edge
|
||||
else{Standard_Failure::Raise("Curves must be type TopoDS_Vertex");} //Raise exception
|
||||
|
||||
}
|
||||
|
||||
else{Standard_Failure::Raise("Point not from Part::Feature");}
|
||||
|
||||
res = builder.Add(BRep_Tool::Pnt(vtmp));
|
||||
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void appinitface(BRepFill_Filling& builder,const App::PropertyLinkSubList& aFace){
|
||||
|
||||
int res;
|
||||
|
||||
if(aFace.getSize()>1){Standard_Failure::Raise("Only one face may be used for the initial face");return;}
|
||||
|
||||
Part::TopoShape ts;
|
||||
// Part::TopoShape sub;
|
||||
TopoDS_Shape sub;
|
||||
TopoDS_Face face;
|
||||
|
||||
//the subset has the documentobject and the element name which belongs to it,
|
||||
// in our case for example the cube object and the "Vertex1" string
|
||||
App::PropertyLinkSubList::SubSet set = aFace[0];
|
||||
|
||||
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);
|
||||
|
||||
if(sub.ShapeType() == TopAbs_FACE) {face = TopoDS::Face(sub);} //Check Shape type and assign edge
|
||||
else{Standard_Failure::Raise("Faces must be type TopoDS_Face");} //Raise exception
|
||||
|
||||
}
|
||||
|
||||
else{Standard_Failure::Raise("Point not from Part::Feature");}
|
||||
|
||||
builder.LoadInitSurface(face);
|
||||
|
||||
return;
|
||||
}
|
||||
77
src/Mod/Surface/App/FeatureFilling.h
Normal file
77
src/Mod/Surface/App/FeatureFilling.h
Normal file
@@ -0,0 +1,77 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2014 Nathan Miller <Nathan.A.Mill[at]gmail.com> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* 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 Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef SURFACE_FEATUREFILLING_H
|
||||
#define SURFACE_FEATUREFILLING_H
|
||||
|
||||
#include <App/PropertyStandard.h>
|
||||
#include <App/PropertyUnits.h>
|
||||
#include <App/PropertyLinks.h>
|
||||
#include "Mod/Part/App/PartFeature.h"
|
||||
|
||||
namespace Surface
|
||||
{
|
||||
|
||||
class SurfaceExport Filling : public Part::Feature
|
||||
{
|
||||
PROPERTY_HEADER(Surface::Filling);
|
||||
|
||||
public:
|
||||
Filling();
|
||||
|
||||
//Properties of Curves
|
||||
|
||||
App::PropertyLinkSubList Border; // Border Edges (C0 is required for edges without a corresponding face)
|
||||
App::PropertyLinkSubList Curves; // Other Constraint Curves (C0 is required for edges without a corresponding face)
|
||||
|
||||
App::PropertyLinkSubList BFaces; // Border Faces (C0, G1 and G2 are possible)
|
||||
App::PropertyIntegerList orderB; // Order of constraint on border faces
|
||||
App::PropertyLinkSubList CFaces; // Curve Faces (C0, G1 and G2 are possible)
|
||||
App::PropertyIntegerList orderC; // Order of constraint on curve faces
|
||||
|
||||
App::PropertyLinkSubList Points; // Constraint Points (on Surface)
|
||||
|
||||
App::PropertyLinkSubList initFace; // Initial Face to use
|
||||
|
||||
//Algorithm Variables
|
||||
App::PropertyInteger Degree; //Starting degree
|
||||
App::PropertyInteger NbPtsOnCur; //Number of points on an edge for constraint
|
||||
App::PropertyInteger NbIter; //Number of iterations
|
||||
App::PropertyBool Anisotropie; //?
|
||||
App::PropertyFloat Tol2d; //2D Tolerance
|
||||
App::PropertyFloat Tol3d; //3D Tolerance
|
||||
App::PropertyFloat TolAng; //G1 tolerance
|
||||
App::PropertyFloat TolCurv; //G2 tolerance
|
||||
App::PropertyInteger MaxDeg; //Maximum curve degree
|
||||
App::PropertyInteger MaxSegments; //Maximum number of segments
|
||||
|
||||
// recalculate the feature
|
||||
App::DocumentObjectExecReturn *execute(void);
|
||||
short mustExecute() const;
|
||||
/// returns the type name of the view provider
|
||||
// const char* getViewProviderName(void) const {
|
||||
// return "PartGui::ViewProviderFilling";
|
||||
// }
|
||||
|
||||
};
|
||||
} //Namespace Surface
|
||||
#endif
|
||||
155
src/Mod/Surface/App/FeatureSewing.cpp
Normal file
155
src/Mod/Surface/App/FeatureSewing.cpp
Normal file
@@ -0,0 +1,155 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2014 Nathan Miller <Nathan.A.Mill[at]gmail.com> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* 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 Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
#include <BRepBuilderAPI_MakeFace.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <Precision.hxx>
|
||||
#endif
|
||||
|
||||
#include "FeatureSewing.h"
|
||||
#include <BRepBuilderAPI_Sewing.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <Base/Tools.h>
|
||||
#include <Base/Exception.h>
|
||||
|
||||
using namespace Surface;
|
||||
|
||||
PROPERTY_SOURCE(Surface::Sewing, Part::Feature)
|
||||
|
||||
//Initial values
|
||||
|
||||
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));
|
||||
|
||||
}
|
||||
|
||||
//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())
|
||||
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
|
||||
|
||||
|
||||
bool res;
|
||||
|
||||
//Begin Construction
|
||||
try{
|
||||
|
||||
BRepBuilderAPI_Sewing builder(atol,opt1,opt2,opt3,opt4);
|
||||
|
||||
addshape(builder,aShapeList);
|
||||
|
||||
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());
|
||||
|
||||
if (aShape.IsNull())
|
||||
return new App::DocumentObjectExecReturn("Resulting shape is null");
|
||||
this->Shape.setValue(aShape);
|
||||
|
||||
|
||||
} //End Try
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
59
src/Mod/Surface/App/FeatureSewing.h
Normal file
59
src/Mod/Surface/App/FeatureSewing.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2014 Nathan Miller <Nathan.A.Mill[at]gmail.com> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* 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 Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef SURFACE_FEATURESEWING_H
|
||||
#define SURFACE_FEATURESEWING_H
|
||||
|
||||
#include <App/PropertyStandard.h>
|
||||
#include <App/PropertyUnits.h>
|
||||
#include <App/PropertyLinks.h>
|
||||
#include "Mod/Part/App/PartFeature.h"
|
||||
|
||||
namespace Surface
|
||||
{
|
||||
|
||||
class SurfaceExport Sewing : public Part::Feature
|
||||
{
|
||||
PROPERTY_HEADER(Surface::Sewing);
|
||||
|
||||
public:
|
||||
Sewing();
|
||||
|
||||
App::PropertyLinkSubList aShapeList; //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
|
||||
|
||||
// recalculate the feature
|
||||
App::DocumentObjectExecReturn *execute(void);
|
||||
short mustExecute() const;
|
||||
/// returns the type name of the view provider
|
||||
// const char* getViewProviderName(void) const {
|
||||
// return "PartGui::ViewProviderSewing";
|
||||
// }
|
||||
|
||||
};
|
||||
}//Namespace Surface
|
||||
#endif
|
||||
47
src/Mod/Surface/App/Makefile.am
Normal file
47
src/Mod/Surface/App/Makefile.am
Normal file
@@ -0,0 +1,47 @@
|
||||
|
||||
lib_LTLIBRARIES=libSurface.la Surface.la
|
||||
|
||||
libSurface_la_SOURCES=\
|
||||
AppSurfacePy.cpp \
|
||||
PreCompiled.cpp \
|
||||
PreCompiled.h
|
||||
|
||||
includedir = @includedir@/Mod/Surface/App
|
||||
|
||||
# the library search path.
|
||||
libSurface_la_LDFLAGS = -L../../../Base -L../../../App $(all_libraries) \
|
||||
-version-info @LIB_CURRENT@:@LIB_REVISION@:@LIB_AGE@
|
||||
libSurface_la_CPPFLAGS = -DSurfaceAppExport=
|
||||
|
||||
libSurface_la_LIBADD = \
|
||||
@BOOST_SYSTEM_LIB@ \
|
||||
-l@PYTHON_LIB@ \
|
||||
-lxerces-c \
|
||||
-lFreeCADBase \
|
||||
-lFreeCADApp
|
||||
|
||||
#--------------------------------------------------------------------------------------
|
||||
# Loader of libSurface
|
||||
|
||||
Surface_la_SOURCES=\
|
||||
AppSurface.cpp
|
||||
|
||||
# the library search path.
|
||||
Surface_la_LDFLAGS = $(libSurface_la_LDFLAGS) -module -avoid-version
|
||||
Surface_la_CPPFLAGS = $(libSurface_la_CPPFLAGS)
|
||||
|
||||
Surface_la_LIBADD = \
|
||||
$(libSurface_la_LIBADD) \
|
||||
-lSurface
|
||||
|
||||
Surface_la_DEPENDENCIES = libSurface.la
|
||||
|
||||
#--------------------------------------------------------------------------------------
|
||||
|
||||
# set the include path found by configure
|
||||
AM_CXXFLAGS = -I$(top_srcdir)/src -I$(top_builddir)/src $(all_includes)
|
||||
|
||||
libdir = $(prefix)/Mod/Surface
|
||||
|
||||
EXTRA_DIST = \
|
||||
CMakeLists.txt
|
||||
24
src/Mod/Surface/App/PreCompiled.cpp
Normal file
24
src/Mod/Surface/App/PreCompiled.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) YEAR YOUR NAME <Your e-mail address> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* 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 Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "PreCompiled.h"
|
||||
65
src/Mod/Surface/App/PreCompiled.h
Normal file
65
src/Mod/Surface/App/PreCompiled.h
Normal file
@@ -0,0 +1,65 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) YEAR YOUR NAME <Your e-mail address> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* 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 Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
//#ifndef APP_PRECOMPILED_H
|
||||
//#define APP_PRECOMPILED_H
|
||||
#ifndef PRECOMPILED_H
|
||||
#define PRECOMPILED_H
|
||||
|
||||
#include <FCConfig.h>
|
||||
|
||||
// Exporting of App classes
|
||||
#ifdef FC_OS_WIN32
|
||||
# define SurfaceExport __declspec(dllexport)
|
||||
# define PartExport __declspec(dllimport)
|
||||
#else // for Linux
|
||||
# define SurfaceExport
|
||||
# define PartExport
|
||||
#endif
|
||||
|
||||
#ifdef _PreComp_
|
||||
|
||||
// standard
|
||||
#include <cstdio>
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
|
||||
// STL
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <queue>
|
||||
#include <set>
|
||||
#include <sstream>
|
||||
#include <stack>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
// Xerces
|
||||
#include <xercesc/util/XercesDefs.hpp>
|
||||
|
||||
#endif //_PreComp_
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user