+ unify DLL export defines to namespace names
git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5000 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d
This commit is contained in:
89
src/Mod/PartDesign/App/AppPartDesign.cpp
Normal file
89
src/Mod/PartDesign/App/AppPartDesign.cpp
Normal file
@@ -0,0 +1,89 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2008 Jürgen Riegel (juergen.riegel@web.de) *
|
||||
* *
|
||||
* 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 <Base/Interpreter.h>
|
||||
|
||||
#include "FeaturePad.h"
|
||||
#include "FeaturePocket.h"
|
||||
#include "FeatureFillet.h"
|
||||
#include "FeatureSketchBased.h"
|
||||
#include "FeatureRevolution.h"
|
||||
#include "FeatureMainPart.h"
|
||||
#include "FeatureDressUp.h"
|
||||
#include "FeatureChamfer.h"
|
||||
#include "FeatureFace.h"
|
||||
#include "FeatureSubtractive.h"
|
||||
#include "FeatureAdditive.h"
|
||||
#include "FeatureHole.h"
|
||||
#include "FeaturePatternRectangular.h"
|
||||
|
||||
extern struct PyMethodDef PartDesign_methods[];
|
||||
|
||||
PyDoc_STRVAR(module_PartDesign_doc,
|
||||
"This module is the PartDesign module.");
|
||||
|
||||
|
||||
/* Python entry */
|
||||
extern "C" {
|
||||
void PartDesignExport initPartDesign()
|
||||
{
|
||||
// load dependent module
|
||||
try {
|
||||
Base::Interpreter().runString("import Part");
|
||||
Base::Interpreter().runString("import Sketcher");
|
||||
}
|
||||
catch(const Base::Exception& e) {
|
||||
PyErr_SetString(PyExc_ImportError, e.what());
|
||||
return;
|
||||
}
|
||||
Py_InitModule3("PartDesign", PartDesign_methods, module_PartDesign_doc); /* mod name, table ptr */
|
||||
Base::Console().Log("Loading PartDesign module... done\n");
|
||||
|
||||
|
||||
// NOTE: To finish the initialization of our own type objects we must
|
||||
// call PyType_Ready, otherwise we run into a segmentation fault, later on.
|
||||
// This function is responsible for adding inherited slots from a type's base class.
|
||||
|
||||
PartDesign::Feature ::init();
|
||||
PartDesign::DressUp ::init();
|
||||
PartDesign::SketchBased ::init();
|
||||
PartDesign::Subtractive ::init();
|
||||
PartDesign::Additive ::init();
|
||||
PartDesign::PatternRectangular ::init();
|
||||
PartDesign::Hole ::init();
|
||||
PartDesign::MainPart ::init();
|
||||
PartDesign::Pad ::init();
|
||||
PartDesign::Pocket ::init();
|
||||
PartDesign::Fillet ::init();
|
||||
PartDesign::Revolution ::init();
|
||||
PartDesign::Chamfer ::init();
|
||||
PartDesign::Face ::init();
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
103
src/Mod/PartDesign/App/AppPartDesignPy.cpp
Normal file
103
src/Mod/PartDesign/App/AppPartDesignPy.cpp
Normal file
@@ -0,0 +1,103 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2008 Jürgen Riegel (juergen.riegel@web.de) *
|
||||
* *
|
||||
* 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/GeometryPyCXX.h>
|
||||
#include <Base/VectorPy.h>
|
||||
#include <Base/Tools.h>
|
||||
|
||||
static PyObject * makeFilletArc(PyObject *self, PyObject *args)
|
||||
{
|
||||
PyObject *pM1;
|
||||
PyObject *pP;
|
||||
PyObject *pQ;
|
||||
PyObject *pN;
|
||||
double r2;
|
||||
int ccw;
|
||||
if (!PyArg_ParseTuple(args, "O!O!O!O!di",
|
||||
&(Base::VectorPy::Type), &pM1,
|
||||
&(Base::VectorPy::Type), &pP,
|
||||
&(Base::VectorPy::Type), &pQ,
|
||||
&(Base::VectorPy::Type), &pN,
|
||||
&r2, &ccw))
|
||||
return NULL;
|
||||
|
||||
Base::Vector3d M1 = Py::Vector(pM1, false).toVector();
|
||||
Base::Vector3d P = Py::Vector(pP, false).toVector();
|
||||
Base::Vector3d Q = Py::Vector(pQ, false).toVector();
|
||||
Base::Vector3d N = Py::Vector(pN, false).toVector();
|
||||
|
||||
Base::Vector3d u = Q - P;
|
||||
Base::Vector3d v = P - M1;
|
||||
Base::Vector3d b;
|
||||
if (ccw)
|
||||
b = u % N;
|
||||
else
|
||||
b = N % u;
|
||||
b.Normalize();
|
||||
|
||||
double uu = u * u;
|
||||
double uv = u * v;
|
||||
double r1 = v.Length();
|
||||
|
||||
// distinguish between internal and external fillets
|
||||
r2 *= Base::sgn(uv);
|
||||
|
||||
double cc = 2.0 * r2 * (b * v - r1);
|
||||
double d = uv * uv - uu * cc;
|
||||
if (d < 0) {
|
||||
PyErr_SetString(PyExc_Exception, "Unable to caluclate intersection points");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
double t;
|
||||
double t1 = (-uv + sqrt(d)) / uu;
|
||||
double t2 = (-uv - sqrt(d)) / uu;
|
||||
|
||||
if (fabs(t1) < fabs(t2))
|
||||
t = t1;
|
||||
else
|
||||
t = t2;
|
||||
|
||||
Base::Vector3d M2 = P + (u*t) + (b*r2);
|
||||
Base::Vector3d S1 = (r2 * M1 + r1 * M2)/(r1+r2);
|
||||
Base::Vector3d S2 = M2 - (b*r2);
|
||||
|
||||
Py::Tuple tuple(3);
|
||||
tuple.setItem(0, Py::Vector(S1));
|
||||
tuple.setItem(1, Py::Vector(S2));
|
||||
tuple.setItem(2, Py::Vector(M2));
|
||||
|
||||
return Py::new_reference_to(tuple);
|
||||
}
|
||||
|
||||
/* registration table */
|
||||
struct PyMethodDef PartDesign_methods[] = {
|
||||
{"makeFilletArc" ,makeFilletArc,METH_VARARGS,
|
||||
"makeFilletArc(...) -- Fillet arc."},
|
||||
{NULL, NULL} /* end of table marker */
|
||||
};
|
||||
108
src/Mod/PartDesign/App/CMakeLists.txt
Normal file
108
src/Mod/PartDesign/App/CMakeLists.txt
Normal file
@@ -0,0 +1,108 @@
|
||||
if(MSVC)
|
||||
add_definitions(-DFCAppPartDesign -DHAVE_ACOSH -DHAVE_ASINH -DHAVE_ATANH)
|
||||
else(MSVC)
|
||||
add_definitions(-DHAVE_LIMITS_H -DHAVE_CONFIG_H)
|
||||
endif(MSVC)
|
||||
|
||||
include_directories(
|
||||
${CMAKE_SOURCE_DIR}/src
|
||||
${Boost_INCLUDE_DIRS}
|
||||
${OCC_INCLUDE_DIR}
|
||||
${ZLIB_INCLUDE_DIR}
|
||||
${PYTHON_INCLUDE_PATH}
|
||||
${XERCESC_INCLUDE_DIR}
|
||||
)
|
||||
link_directories(${OCC_LIBRARY_DIR})
|
||||
|
||||
set(PartDesign_LIBS
|
||||
Part
|
||||
FreeCADApp
|
||||
)
|
||||
|
||||
SET(Features_SRCS
|
||||
Feature.cpp
|
||||
Feature.h
|
||||
FeaturePatternRectangular.h
|
||||
FeaturePatternRectangular.cpp
|
||||
FeatureMainPart.cpp
|
||||
FeatureMainPart.h
|
||||
)
|
||||
SOURCE_GROUP("Features" FILES ${Features_SRCS})
|
||||
|
||||
SET(FeaturesDressUp_SRCS
|
||||
FeatureDressUp.cpp
|
||||
FeatureDressUp.h
|
||||
FeatureFillet.cpp
|
||||
FeatureFillet.h
|
||||
FeatureChamfer.cpp
|
||||
FeatureChamfer.h
|
||||
)
|
||||
SOURCE_GROUP("DressUpFeatures" FILES ${FeaturesDressUp_SRCS})
|
||||
|
||||
SET(FeaturesSketchBased_SRCS
|
||||
FeatureSketchBased.cpp
|
||||
FeatureSketchBased.h
|
||||
FeatureFace.cpp
|
||||
FeatureFace.h
|
||||
FeaturePad.cpp
|
||||
FeaturePad.h
|
||||
FeaturePocket.cpp
|
||||
FeaturePocket.h
|
||||
FeatureRevolution.cpp
|
||||
FeatureRevolution.h
|
||||
FeatureAdditive.cpp
|
||||
FeatureAdditive.h
|
||||
FeatureSubtractive.h
|
||||
FeatureSubtractive.cpp
|
||||
FeatureHole.h
|
||||
FeatureHole.cpp
|
||||
)
|
||||
|
||||
SOURCE_GROUP("SketchBasedFeatures" FILES ${FeaturesSketchBased_SRCS})
|
||||
|
||||
SET(Module_SRCS
|
||||
AppPartDesign.cpp
|
||||
AppPartDesignPy.cpp
|
||||
PreCompiled.cpp
|
||||
PreCompiled.h
|
||||
)
|
||||
SOURCE_GROUP("Module" FILES ${Module_SRCS})
|
||||
|
||||
SET(PartDesign_SRCS
|
||||
${Features_SRCS}
|
||||
${FeaturesSketchBased_SRCS}
|
||||
${FeaturesDressUp_SRCS}
|
||||
${Module_SRCS}
|
||||
)
|
||||
|
||||
SET(PartDesign_Scripts
|
||||
__init__.py
|
||||
Init.py
|
||||
TestPartDesignApp.py
|
||||
Scripts/__init__.py
|
||||
Scripts/Gear.py
|
||||
Scripts/DistanceBolt.py
|
||||
Scripts/RadialCopy.py
|
||||
Scripts/Parallelepiped.py
|
||||
)
|
||||
|
||||
add_library(PartDesign SHARED ${PartDesign_SRCS})
|
||||
target_link_libraries(PartDesign ${PartDesign_LIBS})
|
||||
fc_copy_script("Mod/PartDesign" "PartDesign" ${PartDesign_Scripts})
|
||||
|
||||
if(MSVC)
|
||||
set_target_properties(PartDesign PROPERTIES SUFFIX ".pyd")
|
||||
set_target_properties(PartDesign PROPERTIES DEBUG_OUTPUT_NAME "PartDesign_d")
|
||||
set_target_properties(PartDesign PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Mod/PartDesign)
|
||||
set_target_properties(PartDesign PROPERTIES PREFIX "../")
|
||||
elseif(MINGW)
|
||||
set_target_properties(PartDesign PROPERTIES SUFFIX ".pyd")
|
||||
set_target_properties(PartDesign PROPERTIES DEBUG_OUTPUT_NAME "PartDesign_d")
|
||||
set_target_properties(PartDesign PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Mod/PartDesign)
|
||||
set_target_properties(PartDesign PROPERTIES PREFIX "")
|
||||
else(MSVC)
|
||||
set_target_properties(PartDesign PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Mod/PartDesign)
|
||||
set_target_properties(PartDesign PROPERTIES PREFIX "")
|
||||
endif(MSVC)
|
||||
|
||||
install(TARGETS PartDesign DESTINATION lib)
|
||||
42
src/Mod/PartDesign/App/Feature.cpp
Normal file
42
src/Mod/PartDesign/App/Feature.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2011 Juergen Riegel <FreeCAD@juergen-riegel.net> *
|
||||
* *
|
||||
* 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 "Feature.h"
|
||||
|
||||
|
||||
|
||||
namespace PartDesign {
|
||||
|
||||
|
||||
PROPERTY_SOURCE(PartDesign::Feature,Part::Feature)
|
||||
|
||||
Feature::Feature()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
52
src/Mod/PartDesign/App/Feature.h
Normal file
52
src/Mod/PartDesign/App/Feature.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2011 Juergen Riegel <FreeCAD@juergen-riegel.net> *
|
||||
* *
|
||||
* 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 PARTDESIGN_Feature_H
|
||||
#define PARTDESIGN_Feature_H
|
||||
|
||||
#include <App/PropertyStandard.h>
|
||||
#include <Mod/Part/App/PartFeature.h>
|
||||
|
||||
|
||||
/// Base class of all additive features in PartDesign
|
||||
namespace PartDesign
|
||||
{
|
||||
|
||||
/** PartDesign feature
|
||||
* Base class of all PartDesign features.
|
||||
* This kind of features only produce solids or fail.
|
||||
*/
|
||||
class Feature : public Part::Feature
|
||||
{
|
||||
PROPERTY_HEADER(PartDesign::Feature);
|
||||
|
||||
public:
|
||||
Feature();
|
||||
|
||||
protected:
|
||||
};
|
||||
|
||||
} //namespace PartDesign
|
||||
|
||||
|
||||
#endif // PARTDESIGN_Feature_H
|
||||
44
src/Mod/PartDesign/App/FeatureAdditive.cpp
Normal file
44
src/Mod/PartDesign/App/FeatureAdditive.cpp
Normal file
@@ -0,0 +1,44 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2011 Juergen Riegel <FreeCAD@juergen-riegel.net> *
|
||||
* *
|
||||
* 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 "FeatureAdditive.h"
|
||||
|
||||
|
||||
using namespace PartDesign;
|
||||
|
||||
namespace PartDesign {
|
||||
|
||||
|
||||
PROPERTY_SOURCE(PartDesign::Additive,PartDesign::SketchBased)
|
||||
|
||||
Additive::Additive()
|
||||
{
|
||||
ADD_PROPERTY(AddShape,(TopoDS_Shape()));
|
||||
}
|
||||
|
||||
}
|
||||
51
src/Mod/PartDesign/App/FeatureAdditive.h
Normal file
51
src/Mod/PartDesign/App/FeatureAdditive.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2011 Juergen Riegel <FreeCAD@juergen-riegel.net> *
|
||||
* *
|
||||
* 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 PARTDESIGN_FeatureAdditive_H
|
||||
#define PARTDESIGN_FeatureAdditive_H
|
||||
|
||||
#include <App/PropertyStandard.h>
|
||||
#include <Mod/Part/App/PropertyTopoShape.h>
|
||||
|
||||
#include "FeatureSketchBased.h"
|
||||
|
||||
/// Base class of all additive features in PartDesign
|
||||
namespace PartDesign
|
||||
{
|
||||
|
||||
class Additive : public SketchBased
|
||||
{
|
||||
PROPERTY_HEADER(PartDesign::Additive);
|
||||
|
||||
public:
|
||||
Additive();
|
||||
|
||||
Part::PropertyPartShape AddShape;
|
||||
|
||||
protected:
|
||||
};
|
||||
|
||||
} //namespace PartDesign
|
||||
|
||||
|
||||
#endif // PARTDESIGN_FeatureAdditive_H
|
||||
91
src/Mod/PartDesign/App/FeatureChamfer.cpp
Normal file
91
src/Mod/PartDesign/App/FeatureChamfer.cpp
Normal file
@@ -0,0 +1,91 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2010 Juergen Riegel <FreeCAD@juergen-riegel.net> *
|
||||
* *
|
||||
* 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 <TopExp_Explorer.hxx>
|
||||
# include <TopoDS.hxx>
|
||||
# include <TopoDS_Edge.hxx>
|
||||
#endif
|
||||
|
||||
#include <Mod/Part/App/TopoShape.h>
|
||||
|
||||
#include "FeatureChamfer.h"
|
||||
|
||||
|
||||
using namespace PartDesign;
|
||||
|
||||
|
||||
PROPERTY_SOURCE(PartDesign::Chamfer, PartDesign::DressUp)
|
||||
|
||||
Chamfer::Chamfer()
|
||||
{
|
||||
ADD_PROPERTY(Size,(1.0f));
|
||||
}
|
||||
|
||||
short Chamfer::mustExecute() const
|
||||
{
|
||||
if (Base.isTouched() || Size.isTouched())
|
||||
return 1;
|
||||
if (Base.getValue() && Base.getValue()->isTouched())
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
App::DocumentObjectExecReturn *Chamfer::execute(void)
|
||||
{
|
||||
/* App::DocumentObject* link = Base.getValue();
|
||||
if (!link)
|
||||
return new App::DocumentObjectExecReturn("No object linked");
|
||||
if (!link->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()))
|
||||
return new App::DocumentObjectExecReturn("Linked object is not a Part object");
|
||||
Part::Feature *base = static_cast<Part::Feature*>(Base.getValue());
|
||||
const Part::TopoShape& TopShape = base->Shape.getShape();
|
||||
|
||||
const std::vector<std::string>& SubVals = Base.getSubValuesStartsWith("Edge");
|
||||
if (SubVals.size() == 0)
|
||||
return new App::DocumentObjectExecReturn("No Edges specified");
|
||||
|
||||
float radius = Radius.getValue();
|
||||
|
||||
try {
|
||||
BRepChamferAPI_MakeChamfer mkChamfer(base->Shape.getValue());
|
||||
|
||||
for (std::vector<std::string>::const_iterator it= SubVals.begin();it!=SubVals.end();++it) {
|
||||
TopoDS_Edge edge = TopoDS::Edge(TopShape.getSubShape(it->c_str()));
|
||||
mkChamfer.Add(radius, radius, edge);
|
||||
}
|
||||
|
||||
TopoDS_Shape shape = mkChamfer.Shape();
|
||||
if (shape.IsNull())
|
||||
return new App::DocumentObjectExecReturn("Resulting shape is null");
|
||||
this->Shape.setValue(shape);
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
return new App::DocumentObjectExecReturn(e->GetMessageString());
|
||||
}*/
|
||||
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
58
src/Mod/PartDesign/App/FeatureChamfer.h
Normal file
58
src/Mod/PartDesign/App/FeatureChamfer.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2010 Juergen Riegel <FreeCAD@juergen-riegel.net> *
|
||||
* *
|
||||
* 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 PARTDESIGN_FEATURECHAMFER_H
|
||||
#define PARTDESIGN_FEATURECHAMFER_H
|
||||
|
||||
#include <App/PropertyUnits.h>
|
||||
#include <App/PropertyLinks.h>
|
||||
#include "FeatureDressUp.h"
|
||||
|
||||
namespace PartDesign
|
||||
{
|
||||
|
||||
class Chamfer : public DressUp
|
||||
{
|
||||
PROPERTY_HEADER(PartDesign::Chamfer);
|
||||
|
||||
public:
|
||||
Chamfer();
|
||||
|
||||
App::PropertyLength Size;
|
||||
|
||||
/** @name methods override feature */
|
||||
//@{
|
||||
/// recalculate the feature
|
||||
App::DocumentObjectExecReturn *execute(void);
|
||||
short mustExecute() const;
|
||||
/// returns the type name of the view provider
|
||||
const char* getViewProviderName(void) const {
|
||||
return "PartDesignGui::ViewProviderChamfer";
|
||||
}
|
||||
//@}
|
||||
};
|
||||
|
||||
} //namespace Part
|
||||
|
||||
|
||||
#endif // PARTDESIGN_FEATURECHAMFER_H
|
||||
45
src/Mod/PartDesign/App/FeatureDressUp.cpp
Normal file
45
src/Mod/PartDesign/App/FeatureDressUp.cpp
Normal file
@@ -0,0 +1,45 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2010 Juergen Riegel <FreeCAD@juergen-riegel.net> *
|
||||
* *
|
||||
* 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 "FeatureDressUp.h"
|
||||
|
||||
|
||||
using namespace PartDesign;
|
||||
|
||||
namespace PartDesign {
|
||||
|
||||
|
||||
PROPERTY_SOURCE(PartDesign::DressUp, PartDesign::Feature)
|
||||
|
||||
DressUp::DressUp()
|
||||
{
|
||||
ADD_PROPERTY(Base,(0));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
47
src/Mod/PartDesign/App/FeatureDressUp.h
Normal file
47
src/Mod/PartDesign/App/FeatureDressUp.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2010 Juergen Riegel <FreeCAD@juergen-riegel.net> *
|
||||
* *
|
||||
* 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 PARTDESIGN_DressUp_H
|
||||
#define PARTDESIGN_DressUp_H
|
||||
|
||||
#include <App/PropertyStandard.h>
|
||||
#include "Feature.h"
|
||||
|
||||
namespace PartDesign
|
||||
{
|
||||
|
||||
class DressUp : public PartDesign::Feature
|
||||
{
|
||||
PROPERTY_HEADER(PartDesign::DressUp);
|
||||
|
||||
public:
|
||||
DressUp();
|
||||
|
||||
App::PropertyLinkSub Base;
|
||||
|
||||
};
|
||||
|
||||
} //namespace PartDesign
|
||||
|
||||
|
||||
#endif // PART_DressUp_H
|
||||
218
src/Mod/PartDesign/App/FeatureFace.cpp
Normal file
218
src/Mod/PartDesign/App/FeatureFace.cpp
Normal file
@@ -0,0 +1,218 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2011 Werner Mayer <wmayer[at]users.sourceforge.net> *
|
||||
* *
|
||||
* 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 <Bnd_Box.hxx>
|
||||
# include <gp_Pln.hxx>
|
||||
# include <BRep_Builder.hxx>
|
||||
# include <BRepBndLib.hxx>
|
||||
# include <BRepBuilderAPI_Copy.hxx>
|
||||
# include <BRepBuilderAPI_MakeFace.hxx>
|
||||
# include <BRepAdaptor_Surface.hxx>
|
||||
# include <Geom_Plane.hxx>
|
||||
# include <Handle_Geom_Surface.hxx>
|
||||
# include <TopoDS.hxx>
|
||||
# include <TopoDS_Compound.hxx>
|
||||
# include <TopoDS_Face.hxx>
|
||||
# include <TopoDS_Wire.hxx>
|
||||
# include <TopExp_Explorer.hxx>
|
||||
# include <BRepAlgoAPI_Fuse.hxx>
|
||||
# include <gp_Pln.hxx>
|
||||
#endif
|
||||
|
||||
#include <Base/Placement.h>
|
||||
#include <Mod/Part/App/Part2DObject.h>
|
||||
|
||||
#include "FeatureFace.h"
|
||||
|
||||
|
||||
using namespace PartDesign;
|
||||
|
||||
|
||||
PROPERTY_SOURCE(PartDesign::Face, Part::Part2DObject)
|
||||
|
||||
Face::Face()
|
||||
{
|
||||
ADD_PROPERTY(Sources,(0));
|
||||
Sources.setSize(0);
|
||||
}
|
||||
|
||||
short Face::mustExecute() const
|
||||
{
|
||||
if (Sources.isTouched())
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
App::DocumentObjectExecReturn *Face::execute(void)
|
||||
{
|
||||
std::vector<App::DocumentObject*> links = Sources.getValues();
|
||||
if (links.empty())
|
||||
return new App::DocumentObjectExecReturn("No shapes linked");
|
||||
|
||||
std::vector<TopoDS_Wire> wires;
|
||||
for (std::vector<App::DocumentObject*>::iterator it = links.begin(); it != links.end(); ++it) {
|
||||
if (!(*it && (*it)->isDerivedFrom(Part::Part2DObject::getClassTypeId())))
|
||||
return new App::DocumentObjectExecReturn("Linked object is not a Sketch or Part2DObject");
|
||||
TopoDS_Shape shape = static_cast<Part::Part2DObject*>(*it)->Shape.getShape()._Shape;
|
||||
if (shape.IsNull())
|
||||
return new App::DocumentObjectExecReturn("Linked shape object is empty");
|
||||
|
||||
// this is a workaround for an obscure OCC bug which leads to empty tessellations
|
||||
// for some faces. Making an explicit copy of the linked shape seems to fix it.
|
||||
// The error only happens when re-computing the shape.
|
||||
if (!this->Shape.getValue().IsNull()) {
|
||||
BRepBuilderAPI_Copy copy(shape);
|
||||
shape = copy.Shape();
|
||||
if (shape.IsNull())
|
||||
return new App::DocumentObjectExecReturn("Linked shape object is empty");
|
||||
}
|
||||
|
||||
TopExp_Explorer ex;
|
||||
for (ex.Init(shape, TopAbs_WIRE); ex.More(); ex.Next()) {
|
||||
wires.push_back(TopoDS::Wire(ex.Current()));
|
||||
}
|
||||
}
|
||||
|
||||
if (wires.empty()) // there can be several wires
|
||||
return new App::DocumentObjectExecReturn("Linked shape object is not a wire");
|
||||
|
||||
TopoDS_Shape aFace = makeFace(wires);
|
||||
if (aFace.IsNull())
|
||||
return new App::DocumentObjectExecReturn("Creating a face from sketch failed");
|
||||
this->Shape.setValue(aFace);
|
||||
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
|
||||
namespace PartDesign {
|
||||
|
||||
// sort bounding boxes according to diagonal length
|
||||
struct Wire_Compare {
|
||||
bool operator() (const TopoDS_Wire& w1, const TopoDS_Wire& w2)
|
||||
{
|
||||
Bnd_Box box1, box2;
|
||||
BRepBndLib::Add(w1, box1);
|
||||
box1.SetGap(0.0);
|
||||
|
||||
BRepBndLib::Add(w2, box2);
|
||||
box2.SetGap(0.0);
|
||||
|
||||
return box1.SquareExtent() < box2.SquareExtent();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
TopoDS_Shape Face::makeFace(std::list<TopoDS_Wire>& wires) const
|
||||
{
|
||||
BRepBuilderAPI_MakeFace mkFace(wires.front());
|
||||
const TopoDS_Face& face = mkFace.Face();
|
||||
if (face.IsNull())
|
||||
return face;
|
||||
gp_Dir axis(0,0,1);
|
||||
BRepAdaptor_Surface adapt(face);
|
||||
if (adapt.GetType() == GeomAbs_Plane) {
|
||||
axis = adapt.Plane().Axis().Direction();
|
||||
}
|
||||
|
||||
wires.pop_front();
|
||||
for (std::list<TopoDS_Wire>::iterator it = wires.begin(); it != wires.end(); ++it) {
|
||||
BRepBuilderAPI_MakeFace mkInnerFace(*it);
|
||||
const TopoDS_Face& inner_face = mkInnerFace.Face();
|
||||
gp_Dir inner_axis(0,0,1);
|
||||
BRepAdaptor_Surface adapt(inner_face);
|
||||
if (adapt.GetType() == GeomAbs_Plane) {
|
||||
inner_axis = adapt.Plane().Axis().Direction();
|
||||
}
|
||||
// It seems that orientation is always 'Forward' and we only have to reverse
|
||||
// if the underlying plane have opposite normals.
|
||||
if (axis.Dot(inner_axis) < 0)
|
||||
it->Reverse();
|
||||
mkFace.Add(*it);
|
||||
}
|
||||
return mkFace.Face();
|
||||
}
|
||||
|
||||
TopoDS_Shape Face::makeFace(const std::vector<TopoDS_Wire>& w) const
|
||||
{
|
||||
if (w.empty())
|
||||
return TopoDS_Shape();
|
||||
|
||||
//FIXME: Need a safe method to sort wire that the outermost one comes last
|
||||
// Currently it's done with the diagonal lengths of the bounding boxes
|
||||
std::vector<TopoDS_Wire> wires = w;
|
||||
std::sort(wires.begin(), wires.end(), Wire_Compare());
|
||||
std::list<TopoDS_Wire> wire_list;
|
||||
wire_list.insert(wire_list.begin(), wires.rbegin(), wires.rend());
|
||||
|
||||
// separate the wires into several independent faces
|
||||
std::list< std::list<TopoDS_Wire> > sep_wire_list;
|
||||
while (!wire_list.empty()) {
|
||||
std::list<TopoDS_Wire> sep_list;
|
||||
TopoDS_Wire wire = wire_list.front();
|
||||
wire_list.pop_front();
|
||||
sep_list.push_back(wire);
|
||||
|
||||
Bnd_Box box;
|
||||
BRepBndLib::Add(wire, box);
|
||||
box.SetGap(0.0);
|
||||
|
||||
std::list<TopoDS_Wire>::iterator it = wire_list.begin();
|
||||
while (it != wire_list.end()) {
|
||||
Bnd_Box box2;
|
||||
BRepBndLib::Add(*it, box2);
|
||||
box2.SetGap(0.0);
|
||||
if (!box.IsOut(box2)) {
|
||||
sep_list.push_back(*it);
|
||||
it = wire_list.erase(it);
|
||||
}
|
||||
else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
sep_wire_list.push_back(sep_list);
|
||||
}
|
||||
|
||||
if (sep_wire_list.size() == 1) {
|
||||
std::list<TopoDS_Wire>& wires = sep_wire_list.front();
|
||||
return makeFace(wires);
|
||||
}
|
||||
else if (sep_wire_list.size() > 1) {
|
||||
TopoDS_Compound comp;
|
||||
BRep_Builder builder;
|
||||
builder.MakeCompound(comp);
|
||||
for (std::list< std::list<TopoDS_Wire> >::iterator it = sep_wire_list.begin(); it != sep_wire_list.end(); ++it) {
|
||||
TopoDS_Shape aFace = makeFace(*it);
|
||||
if (!aFace.IsNull())
|
||||
builder.Add(comp, aFace);
|
||||
}
|
||||
|
||||
return comp;
|
||||
}
|
||||
else {
|
||||
return TopoDS_Shape(); // error
|
||||
}
|
||||
}
|
||||
|
||||
56
src/Mod/PartDesign/App/FeatureFace.h
Normal file
56
src/Mod/PartDesign/App/FeatureFace.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2011 Werner Mayer <wmayer[at]users.sourceforge.net> *
|
||||
* *
|
||||
* 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 PARTDESIGN_FACE_H
|
||||
#define PARTDESIGN_FACE_H
|
||||
|
||||
#include <Mod/Part/App/Part2DObject.h>
|
||||
|
||||
namespace PartDesign
|
||||
{
|
||||
|
||||
class Face : public Part::Part2DObject
|
||||
{
|
||||
PROPERTY_HEADER(PartDesign::Face);
|
||||
|
||||
public:
|
||||
Face();
|
||||
|
||||
App::PropertyLinkList Sources;
|
||||
|
||||
/** @name methods override feature */
|
||||
//@{
|
||||
/// recalculate the feature
|
||||
App::DocumentObjectExecReturn *execute(void);
|
||||
short mustExecute() const;
|
||||
//@}
|
||||
|
||||
protected:
|
||||
TopoDS_Shape makeFace(const std::vector<TopoDS_Wire>&) const;
|
||||
TopoDS_Shape makeFace(std::list<TopoDS_Wire>&) const; // for internal use only
|
||||
};
|
||||
|
||||
} //namespace PartDesign
|
||||
|
||||
|
||||
#endif // PARTDESIGN_FACE_H
|
||||
93
src/Mod/PartDesign/App/FeatureFillet.cpp
Normal file
93
src/Mod/PartDesign/App/FeatureFillet.cpp
Normal file
@@ -0,0 +1,93 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2008 Werner Mayer <wmayer[at]users.sourceforge.net> *
|
||||
* *
|
||||
* 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 <BRepFilletAPI_MakeFillet.hxx>
|
||||
# include <TopExp_Explorer.hxx>
|
||||
# include <TopoDS.hxx>
|
||||
# include <TopoDS_Edge.hxx>
|
||||
#endif
|
||||
|
||||
#include <Mod/Part/App/TopoShape.h>
|
||||
|
||||
#include "FeatureFillet.h"
|
||||
|
||||
|
||||
using namespace PartDesign;
|
||||
|
||||
|
||||
PROPERTY_SOURCE(PartDesign::Fillet, PartDesign::DressUp)
|
||||
|
||||
const App::PropertyFloatConstraint::Constraints floatRadius = {0.0f,FLT_MAX,0.1f};
|
||||
|
||||
Fillet::Fillet()
|
||||
{
|
||||
ADD_PROPERTY(Radius,(0.2f));
|
||||
Radius.setConstraints(&floatRadius);
|
||||
}
|
||||
|
||||
short Fillet::mustExecute() const
|
||||
{
|
||||
if (Base.isTouched() || Radius.isTouched())
|
||||
return 1;
|
||||
if (Base.getValue() && Base.getValue()->isTouched())
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
App::DocumentObjectExecReturn *Fillet::execute(void)
|
||||
{
|
||||
App::DocumentObject* link = Base.getValue();
|
||||
if (!link)
|
||||
return new App::DocumentObjectExecReturn("No object linked");
|
||||
if (!link->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()))
|
||||
return new App::DocumentObjectExecReturn("Linked object is not a Part object");
|
||||
Part::Feature *base = static_cast<Part::Feature*>(Base.getValue());
|
||||
const Part::TopoShape& TopShape = base->Shape.getShape();
|
||||
|
||||
const std::vector<std::string>& SubVals = Base.getSubValuesStartsWith("Edge");
|
||||
if (SubVals.size() == 0)
|
||||
return new App::DocumentObjectExecReturn("No Edges specified");
|
||||
|
||||
float radius = Radius.getValue();
|
||||
|
||||
try {
|
||||
BRepFilletAPI_MakeFillet mkFillet(base->Shape.getValue());
|
||||
|
||||
for (std::vector<std::string>::const_iterator it= SubVals.begin();it!=SubVals.end();++it) {
|
||||
TopoDS_Edge edge = TopoDS::Edge(TopShape.getSubShape(it->c_str()));
|
||||
mkFillet.Add(radius, radius, edge);
|
||||
}
|
||||
|
||||
TopoDS_Shape shape = mkFillet.Shape();
|
||||
if (shape.IsNull())
|
||||
return new App::DocumentObjectExecReturn("Resulting shape is null");
|
||||
this->Shape.setValue(shape);
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
return new App::DocumentObjectExecReturn(e->GetMessageString());
|
||||
}
|
||||
}
|
||||
58
src/Mod/PartDesign/App/FeatureFillet.h
Normal file
58
src/Mod/PartDesign/App/FeatureFillet.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2008 Werner Mayer <wmayer[at]users.sourceforge.net> *
|
||||
* *
|
||||
* 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 PARTDESIGN_FEATUREFILLET_H
|
||||
#define PARTDESIGN_FEATUREFILLET_H
|
||||
|
||||
#include <App/PropertyStandard.h>
|
||||
#include <App/PropertyLinks.h>
|
||||
#include "FeatureDressUp.h"
|
||||
|
||||
namespace PartDesign
|
||||
{
|
||||
|
||||
class Fillet : public DressUp
|
||||
{
|
||||
PROPERTY_HEADER(PartDesign::Fillet);
|
||||
|
||||
public:
|
||||
Fillet();
|
||||
|
||||
App::PropertyFloatConstraint Radius;
|
||||
|
||||
/** @name methods override feature */
|
||||
//@{
|
||||
/// 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::ViewProviderFillet";
|
||||
//}
|
||||
//@}
|
||||
};
|
||||
|
||||
} //namespace Part
|
||||
|
||||
|
||||
#endif // PARTDESIGN_FEATUREFILLET_H
|
||||
159
src/Mod/PartDesign/App/FeatureHole.cpp
Normal file
159
src/Mod/PartDesign/App/FeatureHole.cpp
Normal file
@@ -0,0 +1,159 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2011 Juergen Riegel <FreeCAD@juergen-riegel.net> *
|
||||
* *
|
||||
* 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 <Bnd_Box.hxx>
|
||||
# include <gp_Dir.hxx>
|
||||
# include <gp_Pln.hxx>
|
||||
# include <BRep_Builder.hxx>
|
||||
# include <BRepAdaptor_Surface.hxx>
|
||||
# include <BRepBndLib.hxx>
|
||||
# include <BRepPrimAPI_MakePrism.hxx>
|
||||
# include <BRepBuilderAPI_Copy.hxx>
|
||||
# include <BRepBuilderAPI_MakeFace.hxx>
|
||||
# include <Geom_Plane.hxx>
|
||||
# include <Handle_Geom_Surface.hxx>
|
||||
# include <TopoDS.hxx>
|
||||
# include <TopoDS_Face.hxx>
|
||||
# include <TopoDS_Wire.hxx>
|
||||
# include <TopExp_Explorer.hxx>
|
||||
# include <BRepAlgoAPI_Cut.hxx>
|
||||
#endif
|
||||
|
||||
#include <Base/Placement.h>
|
||||
#include <Mod/Part/App/Part2DObject.h>
|
||||
|
||||
#include "FeatureHole.h"
|
||||
|
||||
|
||||
using namespace PartDesign;
|
||||
|
||||
const char* Hole::TypeEnums[] = {"Dimension","UpToLast","UpToFirst",NULL};
|
||||
const char* Hole::HoleTypeEnums[]= {"Simple","Counterbore","Countersunk",NULL};
|
||||
const char* Hole::ThreadEnums[] = {"None","Metric","MetricFine",NULL};
|
||||
|
||||
PROPERTY_SOURCE(PartDesign::Hole, PartDesign::SketchBased)
|
||||
|
||||
Hole::Hole()
|
||||
{
|
||||
ADD_PROPERTY(Type,((long)0));
|
||||
Type.setEnums(TypeEnums);
|
||||
ADD_PROPERTY(HoleType,((long)0));
|
||||
Type.setEnums(HoleTypeEnums);
|
||||
ADD_PROPERTY(ThreadType,((long)0));
|
||||
Type.setEnums(ThreadEnums);
|
||||
ADD_PROPERTY(Length,(100.0));
|
||||
ADD_PROPERTY(ThreadSize,(6.0));
|
||||
}
|
||||
|
||||
//short Hole::mustExecute() const
|
||||
//{
|
||||
// if (Sketch.isTouched() ||
|
||||
// Length.isTouched())
|
||||
// return 1;
|
||||
// return 0;
|
||||
//}
|
||||
|
||||
App::DocumentObjectExecReturn *Hole::execute(void)
|
||||
{
|
||||
//App::DocumentObject* link = Sketch.getValue();
|
||||
//if (!link)
|
||||
// return new App::DocumentObjectExecReturn("No sketch linked");
|
||||
//if (!link->getTypeId().isDerivedFrom(Part::Part2DObject::getClassTypeId()))
|
||||
// return new App::DocumentObjectExecReturn("Linked object is not a Sketch or Part2DObject");
|
||||
//TopoDS_Shape shape = static_cast<Part::Part2DObject*>(link)->Shape.getShape()._Shape;
|
||||
//if (shape.IsNull())
|
||||
// return new App::DocumentObjectExecReturn("Linked shape object is empty");
|
||||
|
||||
//// this is a workaround for an obscure OCC bug which leads to empty tessellations
|
||||
//// for some faces. Making an explicit copy of the linked shape seems to fix it.
|
||||
//// The error almost happens when re-computing the shape but sometimes also for the
|
||||
//// first time
|
||||
//BRepBuilderAPI_Copy copy(shape);
|
||||
//shape = copy.Shape();
|
||||
//if (shape.IsNull())
|
||||
// return new App::DocumentObjectExecReturn("Linked shape object is empty");
|
||||
|
||||
//TopExp_Explorer ex;
|
||||
//std::vector<TopoDS_Wire> wires;
|
||||
//for (ex.Init(shape, TopAbs_WIRE); ex.More(); ex.Next()) {
|
||||
// wires.push_back(TopoDS::Wire(ex.Current()));
|
||||
//}
|
||||
//if (/*shape.ShapeType() != TopAbs_WIRE*/wires.empty()) // there can be several wires
|
||||
// return new App::DocumentObjectExecReturn("Linked shape object is not a wire");
|
||||
|
||||
//// get the Sketch plane
|
||||
//Base::Placement SketchPos = static_cast<Part::Part2DObject*>(link)->Placement.getValue();
|
||||
//Base::Rotation SketchOrientation = SketchPos.getRotation();
|
||||
//Base::Vector3d SketchVector(0,0,1);
|
||||
//SketchOrientation.multVec(SketchVector,SketchVector);
|
||||
|
||||
//// get the support of the Sketch if any
|
||||
//App::DocumentObject* SupportLink = static_cast<Part::Part2DObject*>(link)->Support.getValue();
|
||||
//Part::Feature *SupportObject = 0;
|
||||
//if (SupportLink && SupportLink->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()))
|
||||
// SupportObject = static_cast<Part::Feature*>(SupportLink);
|
||||
|
||||
//if (!SupportObject)
|
||||
// return new App::DocumentObjectExecReturn("No support in Sketch!");
|
||||
|
||||
//TopoDS_Shape aFace = makeFace(wires);
|
||||
//if (aFace.IsNull())
|
||||
// return new App::DocumentObjectExecReturn("Creating a face from sketch failed");
|
||||
|
||||
//// lengthen the vector
|
||||
//SketchVector *= Length.getValue();
|
||||
|
||||
//// turn around for pockets
|
||||
//SketchVector *= -1;
|
||||
|
||||
//// extrude the face to a solid
|
||||
//gp_Vec vec(SketchVector.x,SketchVector.y,SketchVector.z);
|
||||
//BRepPrimAPI_MakePrism PrismMaker(aFace,vec,0,1);
|
||||
//if (PrismMaker.IsDone()) {
|
||||
// // if the sketch has a support fuse them to get one result object (PAD!)
|
||||
// if (SupportObject) {
|
||||
// const TopoDS_Shape& support = SupportObject->Shape.getValue();
|
||||
// if (support.IsNull())
|
||||
// return new App::DocumentObjectExecReturn("Support shape is invalid");
|
||||
// TopExp_Explorer xp (support, TopAbs_SOLID);
|
||||
// if (!xp.More())
|
||||
// return new App::DocumentObjectExecReturn("Support shape is not a solid");
|
||||
// // Let's call algorithm computing a fuse operation:
|
||||
// BRepAlgoAPI_Cut mkCut(support, PrismMaker.Shape());
|
||||
// // Let's check if the fusion has been successful
|
||||
// if (!mkCut.IsDone())
|
||||
// return new App::DocumentObjectExecReturn("Cut with support failed");
|
||||
// this->Shape.setValue(mkCut.Shape());
|
||||
// }
|
||||
// else{
|
||||
// return new App::DocumentObjectExecReturn("Cannot create a tool out of sketch with no support");
|
||||
// }
|
||||
//}
|
||||
//else
|
||||
// return new App::DocumentObjectExecReturn("Could not extrude the sketch!");
|
||||
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
|
||||
66
src/Mod/PartDesign/App/FeatureHole.h
Normal file
66
src/Mod/PartDesign/App/FeatureHole.h
Normal file
@@ -0,0 +1,66 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2011 Juergen Riegel <FreeCAD@juergen-riegel.net> *
|
||||
* *
|
||||
* 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 PARTDESIGN_Hole_H
|
||||
#define PARTDESIGN_Hole_H
|
||||
|
||||
#include <App/PropertyUnits.h>
|
||||
#include "FeatureSubtractive.h"
|
||||
|
||||
namespace PartDesign
|
||||
{
|
||||
|
||||
class Hole : public Subtractive
|
||||
{
|
||||
PROPERTY_HEADER(PartDesign::Hole);
|
||||
|
||||
public:
|
||||
Hole();
|
||||
|
||||
App::PropertyEnumeration Type;
|
||||
App::PropertyEnumeration HoleType;
|
||||
App::PropertyEnumeration ThreadType;
|
||||
App::PropertyLength Length;
|
||||
App::PropertyFloat ThreadSize;
|
||||
|
||||
/** @name methods override feature */
|
||||
//@{
|
||||
/// recalculate the feature
|
||||
App::DocumentObjectExecReturn *execute(void);
|
||||
//short mustExecute() const;
|
||||
/// returns the type name of the view provider
|
||||
const char* getViewProviderName(void) const {
|
||||
return "PartDesignGui::ViewProviderHole";
|
||||
}
|
||||
//@}
|
||||
private:
|
||||
static const char* TypeEnums[];
|
||||
static const char* HoleTypeEnums[];
|
||||
static const char* ThreadEnums[];
|
||||
|
||||
};
|
||||
|
||||
} //namespace PartDesign
|
||||
|
||||
|
||||
#endif // PART_Hole_H
|
||||
60
src/Mod/PartDesign/App/FeatureMainPart.cpp
Normal file
60
src/Mod/PartDesign/App/FeatureMainPart.cpp
Normal file
@@ -0,0 +1,60 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2010 Juergen Riegel <FreeCAD@juergen-riegel.net> *
|
||||
* *
|
||||
* 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 <Base/Placement.h>
|
||||
#include <Mod/Part/App/Part2DObject.h>
|
||||
|
||||
#include "FeatureMainPart.h"
|
||||
|
||||
|
||||
using namespace PartDesign;
|
||||
|
||||
namespace PartDesign {
|
||||
|
||||
|
||||
PROPERTY_SOURCE(PartDesign::MainPart, Part::Feature)
|
||||
|
||||
MainPart::MainPart()
|
||||
{
|
||||
ADD_PROPERTY(Model,(0));
|
||||
}
|
||||
|
||||
short MainPart::mustExecute() const
|
||||
{
|
||||
//if (Sketch.isTouched() ||
|
||||
// Length.isTouched())
|
||||
// return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
App::DocumentObjectExecReturn *MainPart::execute(void)
|
||||
{
|
||||
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
|
||||
}
|
||||
57
src/Mod/PartDesign/App/FeatureMainPart.h
Normal file
57
src/Mod/PartDesign/App/FeatureMainPart.h
Normal file
@@ -0,0 +1,57 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2010 Juergen Riegel <FreeCAD@juergen-riegel.net> *
|
||||
* *
|
||||
* 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 PARTDESIGN_MainPart_H
|
||||
#define PARTDESIGN_MainPart_H
|
||||
|
||||
#include <App/PropertyStandard.h>
|
||||
#include "Feature.h"
|
||||
|
||||
namespace PartDesign
|
||||
{
|
||||
|
||||
class MainPart : public PartDesign::Feature
|
||||
{
|
||||
PROPERTY_HEADER(PartDesign::MainPart);
|
||||
|
||||
public:
|
||||
MainPart();
|
||||
|
||||
App::PropertyLinkList Model;
|
||||
|
||||
/** @name methods override feature */
|
||||
//@{
|
||||
/// recalculate the feature
|
||||
App::DocumentObjectExecReturn *execute(void);
|
||||
short mustExecute() const;
|
||||
/// returns the type name of the view provider
|
||||
//const char* getViewProviderName(void) const {
|
||||
// return "PartDesignGui::ViewProviderMainPart";
|
||||
//}
|
||||
//@}
|
||||
};
|
||||
|
||||
} //namespace PartDesign
|
||||
|
||||
|
||||
#endif // PART_MainPart_H
|
||||
172
src/Mod/PartDesign/App/FeaturePad.cpp
Normal file
172
src/Mod/PartDesign/App/FeaturePad.cpp
Normal file
@@ -0,0 +1,172 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2010 Juergen Riegel <FreeCAD@juergen-riegel.net> *
|
||||
* *
|
||||
* 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 <Bnd_Box.hxx>
|
||||
//# include <gp_Pln.hxx>
|
||||
# include <BRep_Builder.hxx>
|
||||
# include <BRepBndLib.hxx>
|
||||
# include <BRepPrimAPI_MakePrism.hxx>
|
||||
# include <BRepBuilderAPI_Copy.hxx>
|
||||
# include <BRepBuilderAPI_MakeFace.hxx>
|
||||
//# include <Geom_Plane.hxx>
|
||||
# include <Handle_Geom_Surface.hxx>
|
||||
# include <TopoDS.hxx>
|
||||
# include <TopoDS_Solid.hxx>
|
||||
# include <TopoDS_Face.hxx>
|
||||
# include <TopoDS_Wire.hxx>
|
||||
# include <TopExp_Explorer.hxx>
|
||||
# include <BRepAlgoAPI_Fuse.hxx>
|
||||
#endif
|
||||
|
||||
#include <Base/Placement.h>
|
||||
#include <Mod/Part/App/Part2DObject.h>
|
||||
|
||||
#include "FeaturePad.h"
|
||||
|
||||
|
||||
using namespace PartDesign;
|
||||
|
||||
const char* Pad::SideEnums[]= {"Positive","Negative",NULL};
|
||||
|
||||
PROPERTY_SOURCE(PartDesign::Pad, PartDesign::Additive)
|
||||
|
||||
Pad::Pad()
|
||||
{
|
||||
//ADD_PROPERTY(Side,((long)0));
|
||||
//Side.setEnums(SideEnums);
|
||||
ADD_PROPERTY(Length,(100.0));
|
||||
ADD_PROPERTY(Reversed,(0));
|
||||
ADD_PROPERTY(MirroredExtent,(0));
|
||||
|
||||
}
|
||||
|
||||
short Pad::mustExecute() const
|
||||
{
|
||||
if (Sketch.isTouched() ||
|
||||
Length.isTouched() ||
|
||||
MirroredExtent.isTouched() ||
|
||||
Reversed.isTouched())
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
App::DocumentObjectExecReturn *Pad::execute(void)
|
||||
{
|
||||
App::DocumentObject* link = Sketch.getValue();
|
||||
if (!link)
|
||||
return new App::DocumentObjectExecReturn("No sketch linked");
|
||||
if (!link->getTypeId().isDerivedFrom(Part::Part2DObject::getClassTypeId()))
|
||||
return new App::DocumentObjectExecReturn("Linked object is not a Sketch or Part2DObject");
|
||||
TopoDS_Shape shape = static_cast<Part::Part2DObject*>(link)->Shape.getShape()._Shape;
|
||||
if (shape.IsNull())
|
||||
return new App::DocumentObjectExecReturn("Linked shape object is empty");
|
||||
|
||||
// this is a workaround for an obscure OCC bug which leads to empty tessellations
|
||||
// for some faces. Making an explicit copy of the linked shape seems to fix it.
|
||||
// The error almost happens when re-computing the shape but sometimes also for the
|
||||
// first time
|
||||
BRepBuilderAPI_Copy copy(shape);
|
||||
shape = copy.Shape();
|
||||
if (shape.IsNull())
|
||||
return new App::DocumentObjectExecReturn("Linked shape object is empty");
|
||||
|
||||
TopExp_Explorer ex;
|
||||
std::vector<TopoDS_Wire> wires;
|
||||
for (ex.Init(shape, TopAbs_WIRE); ex.More(); ex.Next()) {
|
||||
wires.push_back(TopoDS::Wire(ex.Current()));
|
||||
}
|
||||
if (/*shape.ShapeType() != TopAbs_WIRE*/wires.empty()) // there can be several wires
|
||||
return new App::DocumentObjectExecReturn("Linked shape object is not a wire");
|
||||
|
||||
// get the Sketch plane
|
||||
Base::Placement SketchPos = static_cast<Part::Part2DObject*>(link)->Placement.getValue();
|
||||
Base::Rotation SketchOrientation = SketchPos.getRotation();
|
||||
Base::Vector3d SketchOrientationVector(0,0,1);
|
||||
if (Reversed.getValue()) // negative direction
|
||||
SketchOrientationVector *= -1;
|
||||
SketchOrientation.multVec(SketchOrientationVector,SketchOrientationVector);
|
||||
|
||||
// get the support of the Sketch if any
|
||||
App::DocumentObject* SupportLink = static_cast<Part::Part2DObject*>(link)->Support.getValue();
|
||||
Part::Feature *SupportObject = 0;
|
||||
if (SupportLink && SupportLink->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()))
|
||||
SupportObject = static_cast<Part::Feature*>(SupportLink);
|
||||
|
||||
|
||||
#if 0
|
||||
//TopoDS_Wire theWire = TopoDS::Wire(shape);
|
||||
//TopoDS_Face aFace = BRepBuilderAPI_MakeFace(theWire);
|
||||
#else
|
||||
TopoDS_Shape aFace = makeFace(wires);
|
||||
if (aFace.IsNull())
|
||||
return new App::DocumentObjectExecReturn("Creating a face from sketch failed");
|
||||
#endif
|
||||
// lengthen the vector
|
||||
SketchOrientationVector *= Length.getValue();
|
||||
|
||||
// extrude the face to a solid
|
||||
gp_Vec vec(SketchOrientationVector.x,SketchOrientationVector.y,SketchOrientationVector.z);
|
||||
BRepPrimAPI_MakePrism PrismMaker(aFace,vec,0,1);
|
||||
if (PrismMaker.IsDone()) {
|
||||
TopoDS_Shape result = TopoDS::Solid(PrismMaker.Shape());
|
||||
// set the additive shape property for later usage in e.g. pattern
|
||||
this->AddShape.setValue(result);
|
||||
// if the sketch has a support fuse them to get one result object (PAD!)
|
||||
if (SupportObject) {
|
||||
const TopoDS_Shape& support = SupportObject->Shape.getValue();
|
||||
if (!support.IsNull() && support.ShapeType() == TopAbs_SOLID) {
|
||||
// Let's call algorithm computing a fuse operation:
|
||||
BRepAlgoAPI_Fuse mkFuse(support, result);
|
||||
// Let's check if the fusion has been successful
|
||||
if (!mkFuse.IsDone())
|
||||
return new App::DocumentObjectExecReturn("Fusion with support failed");
|
||||
result = mkFuse.Shape();
|
||||
// we have to get the solids (fuse create seldomly compounds)
|
||||
TopExp_Explorer anExplorer;
|
||||
anExplorer.Init(result,TopAbs_SOLID);
|
||||
//if(
|
||||
// get the first
|
||||
TopoDS_Solid solRes = TopoDS::Solid(anExplorer.Current());
|
||||
|
||||
//TopoDS_Solid solRes = TopoDS::Solid(result);
|
||||
// lets check if the result is a solid
|
||||
//if (result.ShapeType() != TopAbs_SOLID)
|
||||
// return new App::DocumentObjectExecReturn("Resulting shape is not a solid");
|
||||
if (solRes.IsNull())
|
||||
return new App::DocumentObjectExecReturn("Resulting shape is not a solid");
|
||||
this->Shape.setValue(solRes);
|
||||
//this->Shape.setValue(result);
|
||||
}else
|
||||
return new App::DocumentObjectExecReturn("Support is not a solid");
|
||||
}else
|
||||
|
||||
this->Shape.setValue(result);
|
||||
}
|
||||
else
|
||||
return new App::DocumentObjectExecReturn("Could not extrude the sketch!");
|
||||
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
|
||||
63
src/Mod/PartDesign/App/FeaturePad.h
Normal file
63
src/Mod/PartDesign/App/FeaturePad.h
Normal file
@@ -0,0 +1,63 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2010 Juergen Riegel <FreeCAD@juergen-riegel.net> *
|
||||
* *
|
||||
* 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 PARTDESIGN_Pad_H
|
||||
#define PARTDESIGN_Pad_H
|
||||
|
||||
#include <App/PropertyUnits.h>
|
||||
#include <App/PropertyStandard.h>
|
||||
#include "FeatureAdditive.h"
|
||||
|
||||
namespace PartDesign
|
||||
{
|
||||
|
||||
class Pad : public Additive
|
||||
{
|
||||
PROPERTY_HEADER(PartDesign::Pad);
|
||||
|
||||
public:
|
||||
Pad();
|
||||
|
||||
App::PropertyLength Length;
|
||||
//App::PropertyEnumeration Side;
|
||||
App::PropertyBool Reversed;
|
||||
App::PropertyBool MirroredExtent;
|
||||
|
||||
/** @name methods override feature */
|
||||
//@{
|
||||
/// recalculate the feature
|
||||
App::DocumentObjectExecReturn *execute(void);
|
||||
short mustExecute() const;
|
||||
/// returns the type name of the view provider
|
||||
const char* getViewProviderName(void) const {
|
||||
return "PartDesignGui::ViewProviderPad";
|
||||
}
|
||||
//@}
|
||||
private:
|
||||
static const char* SideEnums[];
|
||||
};
|
||||
|
||||
} //namespace PartDesign
|
||||
|
||||
|
||||
#endif // PART_Pad_H
|
||||
153
src/Mod/PartDesign/App/FeaturePatternRectangular.cpp
Normal file
153
src/Mod/PartDesign/App/FeaturePatternRectangular.cpp
Normal file
@@ -0,0 +1,153 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2011 Juergen Riegel <FreeCAD@juergen-riegel.net> *
|
||||
* *
|
||||
* 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 <Bnd_Box.hxx>
|
||||
# include <BRep_Builder.hxx>
|
||||
# include <BRepBndLib.hxx>
|
||||
# include <BRepBuilderAPI_MakeFace.hxx>
|
||||
# include <BRepAdaptor_Surface.hxx>
|
||||
# include <BRepCheck_Analyzer.hxx>
|
||||
# include <TopoDS.hxx>
|
||||
# include <TopoDS_Compound.hxx>
|
||||
# include <TopoDS_Face.hxx>
|
||||
# include <TopoDS_Wire.hxx>
|
||||
# include <TopExp_Explorer.hxx>
|
||||
# include <gp_Pln.hxx>
|
||||
# include <ShapeFix_Face.hxx>
|
||||
# include <ShapeFix_Wire.hxx>
|
||||
# include <ShapeAnalysis.hxx>
|
||||
# include <TopTools_IndexedMapOfShape.hxx>
|
||||
#endif
|
||||
|
||||
|
||||
#include "FeaturePatternRectangular.h"
|
||||
|
||||
|
||||
using namespace PartDesign;
|
||||
|
||||
namespace PartDesign {
|
||||
|
||||
|
||||
PROPERTY_SOURCE(PartDesign::PatternRectangular, PartDesign::Feature)
|
||||
|
||||
PatternRectangular::PatternRectangular()
|
||||
{
|
||||
ADD_PROPERTY(Base,(0));
|
||||
}
|
||||
|
||||
//short PatternRectangular::mustExecute() const
|
||||
//{
|
||||
// if (Sketch.isTouched() ||
|
||||
// Length.isTouched())
|
||||
// return 1;
|
||||
// return 0;
|
||||
//}
|
||||
|
||||
App::DocumentObjectExecReturn *PatternRectangular::execute(void)
|
||||
{
|
||||
//App::DocumentObject* link = Sketch.getValue();
|
||||
//if (!link)
|
||||
// return new App::DocumentObjectExecReturn("No sketch linked");
|
||||
//if (!link->getTypeId().isDerivedFrom(Part::Part2DObject::getClassTypeId()))
|
||||
// return new App::DocumentObjectExecReturn("Linked object is not a Sketch or Part2DObject");
|
||||
//TopoDS_Shape shape = static_cast<Part::Part2DObject*>(link)->Shape.getShape()._Shape;
|
||||
//if (shape.IsNull())
|
||||
// return new App::DocumentObjectExecReturn("Linked shape object is empty");
|
||||
|
||||
//// this is a workaround for an obscure OCC bug which leads to empty tessellations
|
||||
//// for some faces. Making an explicit copy of the linked shape seems to fix it.
|
||||
//// The error almost happens when re-computing the shape but sometimes also for the
|
||||
//// first time
|
||||
//BRepBuilderAPI_Copy copy(shape);
|
||||
//shape = copy.Shape();
|
||||
//if (shape.IsNull())
|
||||
// return new App::DocumentObjectExecReturn("Linked shape object is empty");
|
||||
|
||||
//TopExp_Explorer ex;
|
||||
//std::vector<TopoDS_Wire> wires;
|
||||
//for (ex.Init(shape, TopAbs_WIRE); ex.More(); ex.Next()) {
|
||||
// wires.push_back(TopoDS::Wire(ex.Current()));
|
||||
//}
|
||||
//if (/*shape.ShapeType() != TopAbs_WIRE*/wires.empty()) // there can be several wires
|
||||
// return new App::DocumentObjectExecReturn("Linked shape object is not a wire");
|
||||
|
||||
//// get the Sketch plane
|
||||
//Base::Placement SketchPos = static_cast<Part::Part2DObject*>(link)->Placement.getValue();
|
||||
//Base::Rotation SketchOrientation = SketchPos.getRotation();
|
||||
//Base::Vector3d SketchVector(0,0,1);
|
||||
//SketchOrientation.multVec(SketchVector,SketchVector);
|
||||
|
||||
//// get the support of the Sketch if any
|
||||
//App::DocumentObject* SupportLink = static_cast<Part::Part2DObject*>(link)->Support.getValue();
|
||||
//Part::Feature *SupportObject = 0;
|
||||
//if (SupportLink && SupportLink->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()))
|
||||
// SupportObject = static_cast<Part::Feature*>(SupportLink);
|
||||
|
||||
//if (!SupportObject)
|
||||
// return new App::DocumentObjectExecReturn("No support in Sketch!");
|
||||
|
||||
//TopoDS_Shape aFace = makeFace(wires);
|
||||
//if (aFace.IsNull())
|
||||
// return new App::DocumentObjectExecReturn("Creating a face from sketch failed");
|
||||
|
||||
//// lengthen the vector
|
||||
//SketchVector *= Length.getValue();
|
||||
|
||||
//// turn around for pockets
|
||||
//SketchVector *= -1;
|
||||
|
||||
//// extrude the face to a solid
|
||||
//gp_Vec vec(SketchVector.x,SketchVector.y,SketchVector.z);
|
||||
//BRepPrimAPI_MakePrism PrismMaker(aFace,vec,0,1);
|
||||
//if (PrismMaker.IsDone()) {
|
||||
// // if the sketch has a support fuse them to get one result object (PAD!)
|
||||
// if (SupportObject) {
|
||||
// const TopoDS_Shape& support = SupportObject->Shape.getValue();
|
||||
// if (support.IsNull())
|
||||
// return new App::DocumentObjectExecReturn("Support shape is invalid");
|
||||
// TopExp_Explorer xp (support, TopAbs_SOLID);
|
||||
// if (!xp.More())
|
||||
// return new App::DocumentObjectExecReturn("Support shape is not a solid");
|
||||
// // Let's call algorithm computing a fuse operation:
|
||||
// BRepAlgoAPI_Cut mkCut(support, PrismMaker.Shape());
|
||||
// // Let's check if the fusion has been successful
|
||||
// if (!mkCut.IsDone())
|
||||
// return new App::DocumentObjectExecReturn("Cut with support failed");
|
||||
// this->Shape.setValue(mkCut.Shape());
|
||||
// }
|
||||
// else{
|
||||
// return new App::DocumentObjectExecReturn("Cannot create a tool out of sketch with no support");
|
||||
// }
|
||||
//}
|
||||
//else
|
||||
// return new App::DocumentObjectExecReturn("Could not extrude the sketch!");
|
||||
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
62
src/Mod/PartDesign/App/FeaturePatternRectangular.h
Normal file
62
src/Mod/PartDesign/App/FeaturePatternRectangular.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2011 Juergen Riegel <FreeCAD@juergen-riegel.net> *
|
||||
* *
|
||||
* 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 PARTDESIGN_FeaturePatternRectangular_H
|
||||
#define PARTDESIGN_FeaturePatternRectangular_H
|
||||
|
||||
#include <App/PropertyStandard.h>
|
||||
#include "Feature.h"
|
||||
|
||||
|
||||
namespace PartDesign
|
||||
{
|
||||
|
||||
class PatternRectangular : public PartDesign::Feature
|
||||
{
|
||||
PROPERTY_HEADER(PartDesign::SketchBased);
|
||||
|
||||
public:
|
||||
PatternRectangular();
|
||||
|
||||
App::PropertyLink Base;
|
||||
|
||||
|
||||
/** @name methods override feature */
|
||||
//@{
|
||||
/// recalculate the feature
|
||||
App::DocumentObjectExecReturn *execute(void);
|
||||
//short mustExecute() const;
|
||||
/// returns the type name of the view provider
|
||||
|
||||
const char* getViewProviderName(void) const {
|
||||
return "PartDesignGui::ViewProviderPatternRectangular";
|
||||
}
|
||||
//@}
|
||||
|
||||
protected:
|
||||
};
|
||||
|
||||
} //namespace PartDesign
|
||||
|
||||
|
||||
#endif // PARTDESIGN_FeaturePatternRectangular_H
|
||||
152
src/Mod/PartDesign/App/FeaturePocket.cpp
Normal file
152
src/Mod/PartDesign/App/FeaturePocket.cpp
Normal file
@@ -0,0 +1,152 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2010 Juergen Riegel <FreeCAD@juergen-riegel.net> *
|
||||
* *
|
||||
* 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 <Bnd_Box.hxx>
|
||||
# include <gp_Dir.hxx>
|
||||
# include <gp_Pln.hxx>
|
||||
# include <BRep_Builder.hxx>
|
||||
# include <BRepAdaptor_Surface.hxx>
|
||||
# include <BRepBndLib.hxx>
|
||||
# include <BRepPrimAPI_MakePrism.hxx>
|
||||
# include <BRepBuilderAPI_Copy.hxx>
|
||||
# include <BRepBuilderAPI_MakeFace.hxx>
|
||||
# include <Geom_Plane.hxx>
|
||||
# include <Handle_Geom_Surface.hxx>
|
||||
# include <TopoDS.hxx>
|
||||
# include <TopoDS_Face.hxx>
|
||||
# include <TopoDS_Wire.hxx>
|
||||
# include <TopExp_Explorer.hxx>
|
||||
# include <BRepAlgoAPI_Cut.hxx>
|
||||
#endif
|
||||
|
||||
#include <Base/Placement.h>
|
||||
#include <Mod/Part/App/Part2DObject.h>
|
||||
|
||||
#include "FeaturePocket.h"
|
||||
|
||||
|
||||
using namespace PartDesign;
|
||||
|
||||
const char* Pocket::TypeEnums[]= {"Length","UpToLast","UpToFirst",NULL};
|
||||
|
||||
PROPERTY_SOURCE(PartDesign::Pocket, PartDesign::SketchBased)
|
||||
|
||||
Pocket::Pocket()
|
||||
{
|
||||
ADD_PROPERTY(Type,((long)0));
|
||||
Type.setEnums(TypeEnums);
|
||||
ADD_PROPERTY(Length,(100.0));
|
||||
}
|
||||
|
||||
short Pocket::mustExecute() const
|
||||
{
|
||||
if (Sketch.isTouched() ||
|
||||
Length.isTouched())
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
App::DocumentObjectExecReturn *Pocket::execute(void)
|
||||
{
|
||||
App::DocumentObject* link = Sketch.getValue();
|
||||
if (!link)
|
||||
return new App::DocumentObjectExecReturn("No sketch linked");
|
||||
if (!link->getTypeId().isDerivedFrom(Part::Part2DObject::getClassTypeId()))
|
||||
return new App::DocumentObjectExecReturn("Linked object is not a Sketch or Part2DObject");
|
||||
TopoDS_Shape shape = static_cast<Part::Part2DObject*>(link)->Shape.getShape()._Shape;
|
||||
if (shape.IsNull())
|
||||
return new App::DocumentObjectExecReturn("Linked shape object is empty");
|
||||
|
||||
// this is a workaround for an obscure OCC bug which leads to empty tessellations
|
||||
// for some faces. Making an explicit copy of the linked shape seems to fix it.
|
||||
// The error almost happens when re-computing the shape but sometimes also for the
|
||||
// first time
|
||||
BRepBuilderAPI_Copy copy(shape);
|
||||
shape = copy.Shape();
|
||||
if (shape.IsNull())
|
||||
return new App::DocumentObjectExecReturn("Linked shape object is empty");
|
||||
|
||||
TopExp_Explorer ex;
|
||||
std::vector<TopoDS_Wire> wires;
|
||||
for (ex.Init(shape, TopAbs_WIRE); ex.More(); ex.Next()) {
|
||||
wires.push_back(TopoDS::Wire(ex.Current()));
|
||||
}
|
||||
if (/*shape.ShapeType() != TopAbs_WIRE*/wires.empty()) // there can be several wires
|
||||
return new App::DocumentObjectExecReturn("Linked shape object is not a wire");
|
||||
|
||||
// get the Sketch plane
|
||||
Base::Placement SketchPos = static_cast<Part::Part2DObject*>(link)->Placement.getValue();
|
||||
Base::Rotation SketchOrientation = SketchPos.getRotation();
|
||||
Base::Vector3d SketchVector(0,0,1);
|
||||
SketchOrientation.multVec(SketchVector,SketchVector);
|
||||
|
||||
// get the support of the Sketch if any
|
||||
App::DocumentObject* SupportLink = static_cast<Part::Part2DObject*>(link)->Support.getValue();
|
||||
Part::Feature *SupportObject = 0;
|
||||
if (SupportLink && SupportLink->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()))
|
||||
SupportObject = static_cast<Part::Feature*>(SupportLink);
|
||||
|
||||
if (!SupportObject)
|
||||
return new App::DocumentObjectExecReturn("No support in Sketch!");
|
||||
|
||||
TopoDS_Shape aFace = makeFace(wires);
|
||||
if (aFace.IsNull())
|
||||
return new App::DocumentObjectExecReturn("Creating a face from sketch failed");
|
||||
|
||||
// lengthen the vector
|
||||
SketchVector *= Length.getValue();
|
||||
|
||||
// turn around for pockets
|
||||
SketchVector *= -1;
|
||||
|
||||
// extrude the face to a solid
|
||||
gp_Vec vec(SketchVector.x,SketchVector.y,SketchVector.z);
|
||||
BRepPrimAPI_MakePrism PrismMaker(aFace,vec,0,1);
|
||||
if (PrismMaker.IsDone()) {
|
||||
// if the sketch has a support fuse them to get one result object (PAD!)
|
||||
if (SupportObject) {
|
||||
const TopoDS_Shape& support = SupportObject->Shape.getValue();
|
||||
if (support.IsNull())
|
||||
return new App::DocumentObjectExecReturn("Support shape is invalid");
|
||||
TopExp_Explorer xp (support, TopAbs_SOLID);
|
||||
if (!xp.More())
|
||||
return new App::DocumentObjectExecReturn("Support shape is not a solid");
|
||||
// Let's call algorithm computing a fuse operation:
|
||||
BRepAlgoAPI_Cut mkCut(support, PrismMaker.Shape());
|
||||
// Let's check if the fusion has been successful
|
||||
if (!mkCut.IsDone())
|
||||
return new App::DocumentObjectExecReturn("Cut with support failed");
|
||||
this->Shape.setValue(mkCut.Shape());
|
||||
}
|
||||
else{
|
||||
return new App::DocumentObjectExecReturn("Cannot create a tool out of sketch with no support");
|
||||
}
|
||||
}
|
||||
else
|
||||
return new App::DocumentObjectExecReturn("Could not extrude the sketch!");
|
||||
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
|
||||
61
src/Mod/PartDesign/App/FeaturePocket.h
Normal file
61
src/Mod/PartDesign/App/FeaturePocket.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2009 Juergen Riegel <FreeCAD@juergen-riegel.net> *
|
||||
* *
|
||||
* 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 PARTDESIGN_Pocket_H
|
||||
#define PARTDESIGN_Pocket_H
|
||||
|
||||
#include <App/PropertyUnits.h>
|
||||
#include "FeatureSubtractive.h"
|
||||
|
||||
namespace PartDesign
|
||||
{
|
||||
|
||||
class Pocket : public Subtractive
|
||||
{
|
||||
PROPERTY_HEADER(PartDesign::Pocket);
|
||||
|
||||
public:
|
||||
Pocket();
|
||||
|
||||
App::PropertyEnumeration Type;
|
||||
App::PropertyLength Length;
|
||||
|
||||
/** @name methods override feature */
|
||||
//@{
|
||||
/// recalculate the feature
|
||||
App::DocumentObjectExecReturn *execute(void);
|
||||
short mustExecute() const;
|
||||
/// returns the type name of the view provider
|
||||
const char* getViewProviderName(void) const {
|
||||
return "PartDesignGui::ViewProviderPocket";
|
||||
}
|
||||
//@}
|
||||
private:
|
||||
static const char* TypeEnums[];
|
||||
|
||||
};
|
||||
|
||||
} //namespace PartDesign
|
||||
|
||||
|
||||
#endif // PART_Pocket_H
|
||||
138
src/Mod/PartDesign/App/FeatureRevolution.cpp
Normal file
138
src/Mod/PartDesign/App/FeatureRevolution.cpp
Normal file
@@ -0,0 +1,138 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2010 Juergen Riegel <FreeCAD@juergen-riegel.net> *
|
||||
* *
|
||||
* 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 <BRep_Builder.hxx>
|
||||
# include <BRepBndLib.hxx>
|
||||
# include <BRepPrimAPI_MakeRevol.hxx>
|
||||
# include <BRepBuilderAPI_Copy.hxx>
|
||||
# include <BRepBuilderAPI_MakeFace.hxx>
|
||||
# include <TopoDS.hxx>
|
||||
# include <TopoDS_Face.hxx>
|
||||
# include <TopoDS_Wire.hxx>
|
||||
# include <TopExp_Explorer.hxx>
|
||||
# include <BRepAlgoAPI_Fuse.hxx>
|
||||
#endif
|
||||
|
||||
#include <Base/Placement.h>
|
||||
#include <Mod/Part/App/Part2DObject.h>
|
||||
|
||||
#include "FeatureRevolution.h"
|
||||
|
||||
|
||||
using namespace PartDesign;
|
||||
|
||||
namespace PartDesign {
|
||||
|
||||
|
||||
PROPERTY_SOURCE(PartDesign::Revolution, PartDesign::SketchBased)
|
||||
|
||||
Revolution::Revolution()
|
||||
{
|
||||
ADD_PROPERTY(Base,(Base::Vector3f(0.0f,0.0f,0.0f)));
|
||||
ADD_PROPERTY(Axis,(Base::Vector3f(0.0f,1.0f,0.0f)));
|
||||
ADD_PROPERTY(Angle,(360.0));
|
||||
}
|
||||
|
||||
short Revolution::mustExecute() const
|
||||
{
|
||||
if (Sketch.isTouched() ||
|
||||
Axis.isTouched() ||
|
||||
Base.isTouched() ||
|
||||
Angle.isTouched())
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
App::DocumentObjectExecReturn *Revolution::execute(void)
|
||||
{
|
||||
App::DocumentObject* link = Sketch.getValue();
|
||||
if (!link)
|
||||
return new App::DocumentObjectExecReturn("No sketch linked");
|
||||
if (!link->getTypeId().isDerivedFrom(Part::Part2DObject::getClassTypeId()))
|
||||
return new App::DocumentObjectExecReturn("Linked object is not a Sketch or Part2DObject");
|
||||
TopoDS_Shape shape = static_cast<Part::Part2DObject*>(link)->Shape.getShape()._Shape;
|
||||
if (shape.IsNull())
|
||||
return new App::DocumentObjectExecReturn("Linked shape object is empty");
|
||||
|
||||
// this is a workaround for an obscure OCC bug which leads to empty tessellations
|
||||
// for some faces. Making an explicit copy of the linked shape seems to fix it.
|
||||
// The error only happens when re-computing the shape.
|
||||
if (!this->Shape.getValue().IsNull()) {
|
||||
BRepBuilderAPI_Copy copy(shape);
|
||||
shape = copy.Shape();
|
||||
if (shape.IsNull())
|
||||
return new App::DocumentObjectExecReturn("Linked shape object is empty");
|
||||
}
|
||||
|
||||
TopExp_Explorer ex;
|
||||
std::vector<TopoDS_Wire> wires;
|
||||
for (ex.Init(shape, TopAbs_WIRE); ex.More(); ex.Next()) {
|
||||
wires.push_back(TopoDS::Wire(ex.Current()));
|
||||
}
|
||||
if (wires.empty()) // there can be several wires
|
||||
return new App::DocumentObjectExecReturn("Linked shape object is not a wire");
|
||||
|
||||
Base::Vector3f b = Base.getValue();
|
||||
Base::Vector3f v = Axis.getValue();
|
||||
gp_Pnt pnt(b.x,b.y,b.z);
|
||||
gp_Dir dir(v.x,v.y,v.z);
|
||||
|
||||
// get the support of the Sketch if any
|
||||
App::DocumentObject* SupportLink = static_cast<Part::Part2DObject*>(link)->Support.getValue();
|
||||
Part::Feature *SupportObject = 0;
|
||||
if(SupportLink && SupportLink->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()))
|
||||
SupportObject = static_cast<Part::Feature*>(SupportLink);
|
||||
|
||||
TopoDS_Shape aFace = makeFace(wires);
|
||||
if (aFace.IsNull())
|
||||
return new App::DocumentObjectExecReturn("Creating a face from sketch failed");
|
||||
|
||||
// revolve the face to a solid
|
||||
BRepPrimAPI_MakeRevol RevolMaker(aFace,gp_Ax1(pnt, dir),Angle.getValue()/180.0f*Standard_PI);
|
||||
|
||||
if (RevolMaker.IsDone()) {
|
||||
TopoDS_Shape result = RevolMaker.Shape();
|
||||
// if the sketch has a support fuse them to get one result object (PAD!)
|
||||
if (SupportObject) {
|
||||
const TopoDS_Shape& support = SupportObject->Shape.getValue();
|
||||
if (!support.IsNull() && support.ShapeType() == TopAbs_SOLID) {
|
||||
// Let's call algorithm computing a fuse operation:
|
||||
BRepAlgoAPI_Fuse mkFuse(support, result);
|
||||
// Let's check if the fusion has been successful
|
||||
if (!mkFuse.IsDone())
|
||||
throw Base::Exception("Fusion with support failed");
|
||||
result = mkFuse.Shape();
|
||||
}
|
||||
}
|
||||
|
||||
this->Shape.setValue(result);
|
||||
}
|
||||
else
|
||||
return new App::DocumentObjectExecReturn("Could not extrude the sketch!");
|
||||
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
|
||||
}
|
||||
59
src/Mod/PartDesign/App/FeatureRevolution.h
Normal file
59
src/Mod/PartDesign/App/FeatureRevolution.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2010 Juergen Riegel <FreeCAD@juergen-riegel.net> *
|
||||
* *
|
||||
* 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 PARTDESIGN_Revolution_H
|
||||
#define PARTDESIGN_Revolution_H
|
||||
|
||||
#include <App/PropertyUnits.h>
|
||||
#include "FeatureSketchBased.h"
|
||||
|
||||
namespace PartDesign
|
||||
{
|
||||
|
||||
class Revolution : public SketchBased
|
||||
{
|
||||
PROPERTY_HEADER(PartDesign::Revolution);
|
||||
|
||||
public:
|
||||
Revolution();
|
||||
|
||||
App::PropertyVector Base;
|
||||
App::PropertyVector Axis;
|
||||
App::PropertyAngle Angle;
|
||||
|
||||
/** @name methods override feature */
|
||||
//@{
|
||||
/// recalculate the feature
|
||||
App::DocumentObjectExecReturn *execute(void);
|
||||
short mustExecute() const;
|
||||
/// returns the type name of the view provider
|
||||
const char* getViewProviderName(void) const {
|
||||
return "PartDesignGui::ViewProviderRevolution";
|
||||
}
|
||||
//@}
|
||||
};
|
||||
|
||||
} //namespace PartDesign
|
||||
|
||||
|
||||
#endif // PART_Revolution_H
|
||||
195
src/Mod/PartDesign/App/FeatureSketchBased.cpp
Normal file
195
src/Mod/PartDesign/App/FeatureSketchBased.cpp
Normal file
@@ -0,0 +1,195 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2010 Juergen Riegel <FreeCAD@juergen-riegel.net> *
|
||||
* *
|
||||
* 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 <Bnd_Box.hxx>
|
||||
# include <BRep_Builder.hxx>
|
||||
# include <BRepBndLib.hxx>
|
||||
# include <BRepBuilderAPI_MakeFace.hxx>
|
||||
# include <BRepAdaptor_Surface.hxx>
|
||||
# include <BRepCheck_Analyzer.hxx>
|
||||
# include <TopoDS.hxx>
|
||||
# include <TopoDS_Compound.hxx>
|
||||
# include <TopoDS_Face.hxx>
|
||||
# include <TopoDS_Wire.hxx>
|
||||
# include <TopExp_Explorer.hxx>
|
||||
# include <gp_Pln.hxx>
|
||||
# include <ShapeFix_Face.hxx>
|
||||
# include <ShapeFix_Wire.hxx>
|
||||
# include <ShapeAnalysis.hxx>
|
||||
# include <TopTools_IndexedMapOfShape.hxx>
|
||||
#endif
|
||||
|
||||
|
||||
#include "FeatureSketchBased.h"
|
||||
|
||||
|
||||
using namespace PartDesign;
|
||||
|
||||
namespace PartDesign {
|
||||
|
||||
// sort bounding boxes according to diagonal length
|
||||
struct Wire_Compare {
|
||||
bool operator() (const TopoDS_Wire& w1, const TopoDS_Wire& w2)
|
||||
{
|
||||
Bnd_Box box1, box2;
|
||||
BRepBndLib::Add(w1, box1);
|
||||
box1.SetGap(0.0);
|
||||
|
||||
BRepBndLib::Add(w2, box2);
|
||||
box2.SetGap(0.0);
|
||||
|
||||
return box1.SquareExtent() < box2.SquareExtent();
|
||||
}
|
||||
};
|
||||
|
||||
PROPERTY_SOURCE(PartDesign::SketchBased, PartDesign::Feature)
|
||||
|
||||
SketchBased::SketchBased()
|
||||
{
|
||||
ADD_PROPERTY(Sketch,(0));
|
||||
}
|
||||
|
||||
TopoDS_Face SketchBased::validateFace(const TopoDS_Face& face) const
|
||||
{
|
||||
BRepCheck_Analyzer aChecker(face);
|
||||
if (!aChecker.IsValid()) {
|
||||
TopoDS_Wire outerwire = ShapeAnalysis::OuterWire(face);
|
||||
TopTools_IndexedMapOfShape myMap;
|
||||
myMap.Add(outerwire);
|
||||
|
||||
TopExp_Explorer xp(face,TopAbs_WIRE);
|
||||
ShapeFix_Wire fix;
|
||||
fix.SetFace(face);
|
||||
fix.Load(outerwire);
|
||||
fix.Perform();
|
||||
BRepBuilderAPI_MakeFace mkFace(fix.WireAPIMake());
|
||||
while (xp.More()) {
|
||||
if (!myMap.Contains(xp.Current())) {
|
||||
fix.Load(TopoDS::Wire(xp.Current()));
|
||||
fix.Perform();
|
||||
mkFace.Add(fix.WireAPIMake());
|
||||
}
|
||||
xp.Next();
|
||||
}
|
||||
|
||||
return mkFace.Face();
|
||||
}
|
||||
|
||||
return face;
|
||||
}
|
||||
|
||||
TopoDS_Shape SketchBased::makeFace(std::list<TopoDS_Wire>& wires) const
|
||||
{
|
||||
BRepBuilderAPI_MakeFace mkFace(wires.front());
|
||||
const TopoDS_Face& face = mkFace.Face();
|
||||
if (face.IsNull())
|
||||
return face;
|
||||
gp_Dir axis(0,0,1);
|
||||
BRepAdaptor_Surface adapt(face);
|
||||
if (adapt.GetType() == GeomAbs_Plane) {
|
||||
axis = adapt.Plane().Axis().Direction();
|
||||
}
|
||||
|
||||
wires.pop_front();
|
||||
for (std::list<TopoDS_Wire>::iterator it = wires.begin(); it != wires.end(); ++it) {
|
||||
BRepBuilderAPI_MakeFace mkInnerFace(*it);
|
||||
const TopoDS_Face& inner_face = mkInnerFace.Face();
|
||||
gp_Dir inner_axis(0,0,1);
|
||||
BRepAdaptor_Surface adapt(inner_face);
|
||||
if (adapt.GetType() == GeomAbs_Plane) {
|
||||
inner_axis = adapt.Plane().Axis().Direction();
|
||||
}
|
||||
// It seems that orientation is always 'Forward' and we only have to reverse
|
||||
// if the underlying plane have opposite normals.
|
||||
if (axis.Dot(inner_axis) < 0)
|
||||
it->Reverse();
|
||||
mkFace.Add(*it);
|
||||
}
|
||||
return validateFace(mkFace.Face());
|
||||
}
|
||||
|
||||
TopoDS_Shape SketchBased::makeFace(const std::vector<TopoDS_Wire>& w) const
|
||||
{
|
||||
if (w.empty())
|
||||
return TopoDS_Shape();
|
||||
|
||||
//FIXME: Need a safe method to sort wire that the outermost one comes last
|
||||
// Currently it's done with the diagonal lengths of the bounding boxes
|
||||
std::vector<TopoDS_Wire> wires = w;
|
||||
std::sort(wires.begin(), wires.end(), Wire_Compare());
|
||||
std::list<TopoDS_Wire> wire_list;
|
||||
wire_list.insert(wire_list.begin(), wires.rbegin(), wires.rend());
|
||||
|
||||
// separate the wires into several independent faces
|
||||
std::list< std::list<TopoDS_Wire> > sep_wire_list;
|
||||
while (!wire_list.empty()) {
|
||||
std::list<TopoDS_Wire> sep_list;
|
||||
TopoDS_Wire wire = wire_list.front();
|
||||
wire_list.pop_front();
|
||||
sep_list.push_back(wire);
|
||||
|
||||
Bnd_Box box;
|
||||
BRepBndLib::Add(wire, box);
|
||||
box.SetGap(0.0);
|
||||
|
||||
std::list<TopoDS_Wire>::iterator it = wire_list.begin();
|
||||
while (it != wire_list.end()) {
|
||||
Bnd_Box box2;
|
||||
BRepBndLib::Add(*it, box2);
|
||||
box2.SetGap(0.0);
|
||||
if (!box.IsOut(box2)) {
|
||||
sep_list.push_back(*it);
|
||||
it = wire_list.erase(it);
|
||||
}
|
||||
else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
sep_wire_list.push_back(sep_list);
|
||||
}
|
||||
|
||||
if (sep_wire_list.size() == 1) {
|
||||
std::list<TopoDS_Wire>& wires = sep_wire_list.front();
|
||||
return makeFace(wires);
|
||||
}
|
||||
else if (sep_wire_list.size() > 1) {
|
||||
TopoDS_Compound comp;
|
||||
BRep_Builder builder;
|
||||
builder.MakeCompound(comp);
|
||||
for (std::list< std::list<TopoDS_Wire> >::iterator it = sep_wire_list.begin(); it != sep_wire_list.end(); ++it) {
|
||||
TopoDS_Shape aFace = makeFace(*it);
|
||||
if (!aFace.IsNull())
|
||||
builder.Add(comp, aFace);
|
||||
}
|
||||
|
||||
return comp;
|
||||
}
|
||||
else {
|
||||
return TopoDS_Shape(); // error
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
54
src/Mod/PartDesign/App/FeatureSketchBased.h
Normal file
54
src/Mod/PartDesign/App/FeatureSketchBased.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2010 Juergen Riegel <FreeCAD@juergen-riegel.net> *
|
||||
* *
|
||||
* 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 PARTDESIGN_SketchBased_H
|
||||
#define PARTDESIGN_SketchBased_H
|
||||
|
||||
#include <App/PropertyStandard.h>
|
||||
#include "Feature.h"
|
||||
|
||||
class TopoDS_Face;
|
||||
class TopoDS_Wire;
|
||||
|
||||
namespace PartDesign
|
||||
{
|
||||
|
||||
class SketchBased : public PartDesign::Feature
|
||||
{
|
||||
PROPERTY_HEADER(PartDesign::SketchBased);
|
||||
|
||||
public:
|
||||
SketchBased();
|
||||
|
||||
App::PropertyLink Sketch;
|
||||
|
||||
protected:
|
||||
TopoDS_Face validateFace(const TopoDS_Face&) const;
|
||||
TopoDS_Shape makeFace(const std::vector<TopoDS_Wire>&) const;
|
||||
TopoDS_Shape makeFace(std::list<TopoDS_Wire>&) const; // for internal use only
|
||||
};
|
||||
|
||||
} //namespace PartDesign
|
||||
|
||||
|
||||
#endif // PARTDESIGN_SketchBased_H
|
||||
44
src/Mod/PartDesign/App/FeatureSubtractive.cpp
Normal file
44
src/Mod/PartDesign/App/FeatureSubtractive.cpp
Normal file
@@ -0,0 +1,44 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2011 Juergen Riegel <FreeCAD@juergen-riegel.net> *
|
||||
* *
|
||||
* 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 "FeatureSubtractive.h"
|
||||
|
||||
|
||||
|
||||
namespace PartDesign {
|
||||
|
||||
|
||||
|
||||
PROPERTY_SOURCE(PartDesign::Subtractive,PartDesign::SketchBased)
|
||||
|
||||
Subtractive::Subtractive()
|
||||
{
|
||||
ADD_PROPERTY(SubShape,(TopoDS_Shape()));
|
||||
}
|
||||
|
||||
}
|
||||
50
src/Mod/PartDesign/App/FeatureSubtractive.h
Normal file
50
src/Mod/PartDesign/App/FeatureSubtractive.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2011 Juergen Riegel <FreeCAD@juergen-riegel.net> *
|
||||
* *
|
||||
* 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 PARTDESIGN_FeatureSubtractive_H
|
||||
#define PARTDESIGN_FeatureSubtractive_H
|
||||
|
||||
#include <App/PropertyStandard.h>
|
||||
#include <Mod/Part/App/PropertyTopoShape.h>
|
||||
|
||||
#include "FeatureSketchBased.h"
|
||||
|
||||
namespace PartDesign
|
||||
{
|
||||
|
||||
class Subtractive : public SketchBased
|
||||
{
|
||||
PROPERTY_HEADER(PartDesign::Subtractive);
|
||||
|
||||
public:
|
||||
Subtractive();
|
||||
|
||||
Part::PropertyPartShape SubShape;
|
||||
|
||||
protected:
|
||||
};
|
||||
|
||||
} //namespace PartDesign
|
||||
|
||||
|
||||
#endif // PARTDESIGN_FeatureSubtractive_H
|
||||
91
src/Mod/PartDesign/App/Makefile.am
Normal file
91
src/Mod/PartDesign/App/Makefile.am
Normal file
@@ -0,0 +1,91 @@
|
||||
|
||||
lib_LTLIBRARIES=libPartDesign.la PartDesign.la
|
||||
|
||||
libPartDesign_la_SOURCES=\
|
||||
AppPartDesignPy.cpp \
|
||||
Feature.cpp \
|
||||
Feature.h \
|
||||
FeatureFace.cpp \
|
||||
FeatureFace.h \
|
||||
FeatureFillet.cpp \
|
||||
FeatureFillet.h \
|
||||
FeaturePad.cpp \
|
||||
FeaturePad.h \
|
||||
FeaturePocket.cpp \
|
||||
FeaturePocket.h \
|
||||
FeatureChamfer.cpp \
|
||||
FeatureChamfer.h \
|
||||
FeatureDressUp.cpp \
|
||||
FeatureDressUp.h \
|
||||
FeatureMainPart.cpp \
|
||||
FeatureMainPart.h \
|
||||
FeatureSketchBased.cpp \
|
||||
FeatureSketchBased.h \
|
||||
FeatureRevolution.cpp \
|
||||
FeatureRevolution.h \
|
||||
FeatureAdditive.cpp \
|
||||
FeatureAdditive.h \
|
||||
FeaturePatternRectangular.cpp \
|
||||
FeaturePatternRectangular.h \
|
||||
FeatureSubtractive.cpp \
|
||||
FeatureSubtractive.h \
|
||||
FeatureHole.cpp \
|
||||
FeatureHole.h \
|
||||
PreCompiled.cpp \
|
||||
PreCompiled.h
|
||||
|
||||
|
||||
# the library search path.
|
||||
libPartDesign_la_LDFLAGS = -L../../../Base -L../../../App -L../../../Mod/Part/App \
|
||||
-L$(OCC_LIB) $(all_libraries) -version-info @LIB_CURRENT@:@LIB_REVISION@:@LIB_AGE@
|
||||
libPartDesign_la_CPPFLAGS = -DPartDesignAppExport=
|
||||
|
||||
libPartDesign_la_LIBADD = \
|
||||
@BOOST_REGEX_LIB@ @BOOST_SYSTEM_LIB@ \
|
||||
-l@PYTHON_LIB@ \
|
||||
-lxerces-c \
|
||||
-lFreeCADBase \
|
||||
-lFreeCADApp \
|
||||
-lPart \
|
||||
-lTKernel \
|
||||
-lTKG2d \
|
||||
-lTKG3d \
|
||||
-lTKMath \
|
||||
-lTKXSBase \
|
||||
-lTKBRep \
|
||||
-lTKGeomAlgo \
|
||||
-lTKGeomBase \
|
||||
-lTKOffset \
|
||||
-lTKPrim \
|
||||
-lTKFillet \
|
||||
-lTKShHealing \
|
||||
-lTKBool \
|
||||
-lTKBO \
|
||||
-lTKTopAlgo
|
||||
|
||||
#--------------------------------------------------------------------------------------
|
||||
# Loader of libPartDesign
|
||||
|
||||
PartDesign_la_SOURCES=\
|
||||
AppPartDesign.cpp
|
||||
|
||||
# the library search path.
|
||||
PartDesign_la_LDFLAGS = $(libPartDesign_la_LDFLAGS) -module -avoid-version
|
||||
PartDesign_la_CPPFLAGS = $(libPartDesign_la_CPPFLAGS)
|
||||
|
||||
PartDesign_la_LIBADD = \
|
||||
$(libPartDesign_la_LIBADD) \
|
||||
-lPartDesign
|
||||
|
||||
PartDesign_la_DEPENDENCIES = libPartDesign.la
|
||||
|
||||
#--------------------------------------------------------------------------------------
|
||||
|
||||
# set the include path found by configure
|
||||
AM_CXXFLAGS = -I$(OCC_INC) -I$(top_srcdir)/src -I$(top_builddir)/src $(all_includes)
|
||||
|
||||
|
||||
libdir = $(prefix)/Mod/PartDesign
|
||||
|
||||
EXTRA_DIST = \
|
||||
CMakeLists.txt
|
||||
24
src/Mod/PartDesign/App/PreCompiled.cpp
Normal file
24
src/Mod/PartDesign/App/PreCompiled.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2008 Jürgen Riegel (juergen.riegel@web.de) *
|
||||
* *
|
||||
* 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"
|
||||
60
src/Mod/PartDesign/App/PreCompiled.h
Normal file
60
src/Mod/PartDesign/App/PreCompiled.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2008 Jürgen Riegel (juergen.riegel@web.de) *
|
||||
* *
|
||||
* 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 __PRECOMPILED__
|
||||
#define __PRECOMPILED__
|
||||
|
||||
#include <FCConfig.h>
|
||||
|
||||
// Exporting of App classes
|
||||
#ifdef FC_OS_WIN32
|
||||
# define PartDesignExport __declspec(dllexport)
|
||||
# define PartExport __declspec(dllimport)
|
||||
# define MeshExport __declspec(dllimport)
|
||||
#else // for Linux
|
||||
# define PartDesignExport
|
||||
# define PartExport
|
||||
# define MeshExport
|
||||
#endif
|
||||
|
||||
#ifdef _PreComp_
|
||||
|
||||
// standard
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <set>
|
||||
#include <bitset>
|
||||
|
||||
// OpenCasCade =====================================================================================
|
||||
#include <Mod/Part/App/OpenCascadeAll.h>
|
||||
|
||||
#include <Python.h>
|
||||
|
||||
#endif // _PreComp_
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user