+ 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:
62
src/Mod/Drawing/App/AppDrawing.cpp
Normal file
62
src/Mod/Drawing/App/AppDrawing.cpp
Normal file
@@ -0,0 +1,62 @@
|
||||
/***************************************************************************
|
||||
* *
|
||||
* This program 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. *
|
||||
* for detail see the LICENCE text file. *
|
||||
* Jürgen Riegel 2007 *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <Python.h>
|
||||
#endif
|
||||
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Interpreter.h>
|
||||
|
||||
#include "FeaturePage.h"
|
||||
#include "FeatureView.h"
|
||||
#include "FeatureViewPart.h"
|
||||
#include "FeatureProjection.h"
|
||||
#include "PageGroup.h"
|
||||
|
||||
extern struct PyMethodDef Drawing_methods[];
|
||||
|
||||
PyDoc_STRVAR(module_drawing_doc,
|
||||
"This module is the drawing module.");
|
||||
|
||||
|
||||
/* Python entry */
|
||||
extern "C" {
|
||||
void DrawingExport initDrawing()
|
||||
{
|
||||
// load dependent module
|
||||
try {
|
||||
Base::Interpreter().loadModule("Part");
|
||||
//Base::Interpreter().loadModule("Mesh");
|
||||
}
|
||||
catch(const Base::Exception& e) {
|
||||
PyErr_SetString(PyExc_ImportError, e.what());
|
||||
return;
|
||||
}
|
||||
Py_InitModule3("Drawing", Drawing_methods, module_drawing_doc); /* mod name, table ptr */
|
||||
Base::Console().Log("Loading Drawing 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.
|
||||
|
||||
Drawing::FeaturePage ::init();
|
||||
Drawing::FeatureView ::init();
|
||||
Drawing::FeatureViewPart ::init();
|
||||
Drawing::PageGroup ::init();
|
||||
Drawing::FeatureProjection ::init();
|
||||
Drawing::FeatureViewPartPython ::init();
|
||||
Drawing::FeatureViewPython ::init();
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
139
src/Mod/Drawing/App/AppDrawingPy.cpp
Normal file
139
src/Mod/Drawing/App/AppDrawingPy.cpp
Normal file
@@ -0,0 +1,139 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) Jürgen Riegel (juergen.riegel@web.de) 2002 *
|
||||
* *
|
||||
* 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 <Mod/Part/App/TopoShapePy.h>
|
||||
#include "ProjectionAlgos.h"
|
||||
#include <Base/Console.h>
|
||||
#include <Base/VectorPy.h>
|
||||
|
||||
|
||||
using namespace Drawing;
|
||||
using namespace Part;
|
||||
|
||||
static PyObject *
|
||||
project(PyObject *self, PyObject *args)
|
||||
{
|
||||
PyObject *pcObjShape;
|
||||
PyObject *pcObjDir=0;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O!|O!", &(TopoShapePy::Type), &pcObjShape,&(Base::VectorPy::Type), &pcObjDir)) // convert args: Python->C
|
||||
return NULL; // NULL triggers exception
|
||||
|
||||
PY_TRY {
|
||||
TopoShapePy* pShape = static_cast<TopoShapePy*>(pcObjShape);
|
||||
Base::Vector3d Vector(0,0,1);
|
||||
if (pcObjDir)
|
||||
Vector = *static_cast<Base::VectorPy*>(pcObjDir)->getVectorPtr();
|
||||
|
||||
ProjectionAlgos Alg(pShape->getTopoShapePtr()->_Shape,Base::Vector3f((float)Vector.x,(float)Vector.y,(float)Vector.z));
|
||||
|
||||
Py::List list;
|
||||
list.append(Py::Object(new TopoShapePy(new TopoShape(Alg.V)) , true));
|
||||
list.append(Py::Object(new TopoShapePy(new TopoShape(Alg.V1)), true));
|
||||
list.append(Py::Object(new TopoShapePy(new TopoShape(Alg.H)) , true));
|
||||
list.append(Py::Object(new TopoShapePy(new TopoShape(Alg.H1)), true));
|
||||
|
||||
return Py::new_reference_to(list);
|
||||
|
||||
} PY_CATCH;
|
||||
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
projectEx(PyObject *self, PyObject *args)
|
||||
{
|
||||
PyObject *pcObjShape;
|
||||
PyObject *pcObjDir=0;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O!|O!", &(TopoShapePy::Type), &pcObjShape,&(Base::VectorPy::Type), &pcObjDir)) // convert args: Python->C
|
||||
return NULL; // NULL triggers exception
|
||||
|
||||
PY_TRY {
|
||||
TopoShapePy* pShape = static_cast<TopoShapePy*>(pcObjShape);
|
||||
Base::Vector3d Vector(0,0,1);
|
||||
if (pcObjDir)
|
||||
Vector = *static_cast<Base::VectorPy*>(pcObjDir)->getVectorPtr();
|
||||
|
||||
ProjectionAlgos Alg(pShape->getTopoShapePtr()->_Shape,Base::Vector3f((float)Vector.x,(float)Vector.y,(float)Vector.z));
|
||||
|
||||
Py::List list;
|
||||
list.append(Py::Object(new TopoShapePy(new TopoShape(Alg.V)) , true));
|
||||
list.append(Py::Object(new TopoShapePy(new TopoShape(Alg.V1)), true));
|
||||
list.append(Py::Object(new TopoShapePy(new TopoShape(Alg.VN)), true));
|
||||
list.append(Py::Object(new TopoShapePy(new TopoShape(Alg.VO)), true));
|
||||
list.append(Py::Object(new TopoShapePy(new TopoShape(Alg.VI)), true));
|
||||
list.append(Py::Object(new TopoShapePy(new TopoShape(Alg.H)) , true));
|
||||
list.append(Py::Object(new TopoShapePy(new TopoShape(Alg.H1)), true));
|
||||
list.append(Py::Object(new TopoShapePy(new TopoShape(Alg.HN)), true));
|
||||
list.append(Py::Object(new TopoShapePy(new TopoShape(Alg.HO)), true));
|
||||
list.append(Py::Object(new TopoShapePy(new TopoShape(Alg.HI)), true));
|
||||
|
||||
return Py::new_reference_to(list);
|
||||
|
||||
} PY_CATCH;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
projectToSVG(PyObject *self, PyObject *args)
|
||||
{
|
||||
PyObject *pcObjShape;
|
||||
PyObject *pcObjDir=0;
|
||||
const char *type=0;
|
||||
float scale=1.0f;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O!|O!sf", &(TopoShapePy::Type), &pcObjShape,
|
||||
&(Base::VectorPy::Type), &pcObjDir, &type, &scale))
|
||||
return NULL;
|
||||
|
||||
PY_TRY {
|
||||
TopoShapePy* pShape = static_cast<TopoShapePy*>(pcObjShape);
|
||||
Base::Vector3d Vector(0,0,1);
|
||||
if (pcObjDir)
|
||||
Vector = static_cast<Base::VectorPy*>(pcObjDir)->value();
|
||||
ProjectionAlgos Alg(pShape->getTopoShapePtr()->_Shape,Base::Vector3f((float)Vector.x,(float)Vector.y,(float)Vector.z));
|
||||
|
||||
bool hidden = false;
|
||||
if (type && std::string(type) == "ShowHiddenLines")
|
||||
hidden = true;
|
||||
|
||||
Py::String result(Alg.getSVG(hidden?ProjectionAlgos::WithHidden:ProjectionAlgos::Plain, scale));
|
||||
return Py::new_reference_to(result);
|
||||
|
||||
} PY_CATCH;
|
||||
}
|
||||
|
||||
/* registration table */
|
||||
struct PyMethodDef Drawing_methods[] = {
|
||||
{"project" ,project ,METH_VARARGS,
|
||||
"[visiblyG0,visiblyG1,hiddenG0,hiddenG1] = project(TopoShape[,App.Vector Direction, string type]) -- Project a shape and return the visible/invisible parts of it."},
|
||||
{"projectEx" ,projectEx ,METH_VARARGS,
|
||||
"[V,V1,VN,VO,VI,H,H1,HN,HO,HI] = projectEx(TopoShape[,App.Vector Direction, string type]) -- Project a shape and return the all parts of it."},
|
||||
{"projectToSVG" ,projectToSVG ,METH_VARARGS,
|
||||
"string = projectToSVG(TopoShape[,App.Vector Direction, string type]) -- Project a shape and return the SVG representation as string."},
|
||||
{NULL, NULL} /* end of table marker */
|
||||
};
|
||||
82
src/Mod/Drawing/App/CMakeLists.txt
Normal file
82
src/Mod/Drawing/App/CMakeLists.txt
Normal file
@@ -0,0 +1,82 @@
|
||||
if(MSVC)
|
||||
add_definitions(-DFCAppDrawing -DHAVE_ACOSH -DHAVE_ASINH -DHAVE_ATANH)
|
||||
else(MSVC)
|
||||
add_definitions(-DHAVE_LIMITS_H -DHAVE_CONFIG_H -DHAVE_ACOSH -DHAVE_ATANH -DHAVE_ASINH)
|
||||
endif(MSVC)
|
||||
|
||||
include_directories(
|
||||
${Boost_INCLUDE_DIRS}
|
||||
${OCC_INCLUDE_DIR}
|
||||
${ZLIB_INCLUDE_DIR}
|
||||
${PYTHON_INCLUDE_PATH}
|
||||
${XERCESC_INCLUDE_DIR}
|
||||
)
|
||||
link_directories(${OCC_LIBRARY_DIR})
|
||||
|
||||
set(Drawing_LIBS
|
||||
Part
|
||||
FreeCADApp
|
||||
)
|
||||
|
||||
SET(Features_SRCS
|
||||
FeaturePage.cpp
|
||||
FeaturePage.h
|
||||
FeatureProjection.cpp
|
||||
FeatureProjection.h
|
||||
FeatureView.cpp
|
||||
FeatureView.h
|
||||
FeatureViewPart.cpp
|
||||
FeatureViewPart.h
|
||||
PageGroup.cpp
|
||||
PageGroup.h
|
||||
)
|
||||
|
||||
SET(Drawing_SRCS
|
||||
AppDrawing.cpp
|
||||
AppDrawingPy.cpp
|
||||
PreCompiled.cpp
|
||||
PreCompiled.h
|
||||
)
|
||||
|
||||
SET(DrawingAlgos_SRCS
|
||||
ProjectionAlgos.cpp
|
||||
ProjectionAlgos.h
|
||||
)
|
||||
|
||||
SOURCE_GROUP("Mod" FILES ${Drawing_SRCS})
|
||||
SOURCE_GROUP("Features" FILES ${Features_SRCS})
|
||||
SOURCE_GROUP("Algorithms" FILES ${DrawingAlgos_SRCS})
|
||||
|
||||
SET(Drawing_Templates
|
||||
Templates/A3_Landscape.svg
|
||||
Templates/A4_Simple.svg
|
||||
)
|
||||
|
||||
if(MSVC)
|
||||
add_definitions(-D_PreComp_)
|
||||
GET_MSVC_PRECOMPILED_SOURCE("PreCompiled.cpp" Drawing_CPP_SRCS ${Drawing_SRCS} ${Features_SRCS} ${DrawingAlgos_SRCS})
|
||||
ADD_MSVC_PRECOMPILED_HEADER("PreCompiled.h" "PreCompiled.cpp" Drawing_CPP_SRCS)
|
||||
endif(MSVC)
|
||||
|
||||
add_library(Drawing SHARED ${Drawing_SRCS} ${Features_SRCS} ${DrawingAlgos_SRCS})
|
||||
target_link_libraries(Drawing ${Drawing_LIBS})
|
||||
fc_copy_script("Mod/Drawing" "Drawing" Init.py)
|
||||
fc_copy_script("Mod/Drawing" "Drawing" DrawingAlgos.py)
|
||||
fc_copy_script("Mod/Drawing" "Drawing" ${Drawing_Templates})
|
||||
|
||||
if(MSVC)
|
||||
set_target_properties(Drawing PROPERTIES SUFFIX ".pyd")
|
||||
set_target_properties(Drawing PROPERTIES DEBUG_OUTPUT_NAME "Drawing_d")
|
||||
set_target_properties(Drawing PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Mod/Drawing)
|
||||
set_target_properties(Drawing PROPERTIES PREFIX "../")
|
||||
elseif(MINGW)
|
||||
set_target_properties(Drawing PROPERTIES SUFFIX ".pyd")
|
||||
set_target_properties(Drawing PROPERTIES DEBUG_OUTPUT_NAME "Drawing_d")
|
||||
set_target_properties(Drawing PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Mod/Drawing)
|
||||
set_target_properties(Drawing PROPERTIES PREFIX "")
|
||||
else(MSVC)
|
||||
set_target_properties(Drawing PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Mod/Drawing)
|
||||
set_target_properties(Drawing PROPERTIES PREFIX "")
|
||||
endif(MSVC)
|
||||
|
||||
install(TARGETS Drawing DESTINATION lib)
|
||||
142
src/Mod/Drawing/App/FeaturePage.cpp
Normal file
142
src/Mod/Drawing/App/FeaturePage.cpp
Normal file
@@ -0,0 +1,142 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) Jürgen Riegel (juergen.riegel@web.de) 2002 *
|
||||
* *
|
||||
* 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 <sstream>
|
||||
#endif
|
||||
|
||||
|
||||
#include <Base/Exception.h>
|
||||
#include <Base/Console.h>
|
||||
#include <Base/FileInfo.h>
|
||||
#include <App/Application.h>
|
||||
#include <boost/regex.hpp>
|
||||
#include <iostream>
|
||||
|
||||
#include "FeaturePage.h"
|
||||
#include "FeatureView.h"
|
||||
|
||||
using namespace Drawing;
|
||||
using namespace std;
|
||||
|
||||
|
||||
//===========================================================================
|
||||
// FeaturePage
|
||||
//===========================================================================
|
||||
|
||||
PROPERTY_SOURCE(Drawing::FeaturePage, App::DocumentObjectGroup)
|
||||
|
||||
const char *group = "Drawing view";
|
||||
|
||||
FeaturePage::FeaturePage(void)
|
||||
{
|
||||
static const char *group = "Drawing view";
|
||||
|
||||
ADD_PROPERTY_TYPE(PageResult ,(0),group,App::Prop_Output,"Resulting SVG document of that page");
|
||||
ADD_PROPERTY_TYPE(Template ,(""),group,App::Prop_None ,"Template for the page");
|
||||
}
|
||||
|
||||
FeaturePage::~FeaturePage()
|
||||
{
|
||||
}
|
||||
|
||||
/// get called by the container when a Property was changed
|
||||
void FeaturePage::onChanged(const App::Property* prop)
|
||||
{
|
||||
if (prop == &PageResult) {
|
||||
if (this->isRestoring()) {
|
||||
// When loading a document the included file
|
||||
// doesn't need to exist at this point.
|
||||
Base::FileInfo fi(PageResult.getValue());
|
||||
if (!fi.exists())
|
||||
return;
|
||||
}
|
||||
}
|
||||
App::DocumentObjectGroup::onChanged(prop);
|
||||
}
|
||||
|
||||
App::DocumentObjectExecReturn *FeaturePage::execute(void)
|
||||
{
|
||||
if(Template.getValue() == "")
|
||||
return App::DocumentObject::StdReturn;
|
||||
|
||||
Base::FileInfo fi(Template.getValue());
|
||||
if (!fi.isReadable()) {
|
||||
// if there is a old absolute template file set use a redirect
|
||||
fi.setFile(App::Application::getResourceDir() + "Mod/Drawing/Templates/" + fi.fileName());
|
||||
// try the redirect
|
||||
if (!fi.isReadable()) {
|
||||
Base::Console().Log("FeaturePage::execute() not able to open %s!\n",Template.getValue());
|
||||
std::string error = std::string("Cannot open file ") + Template.getValue();
|
||||
return new App::DocumentObjectExecReturn(error);
|
||||
}
|
||||
}
|
||||
|
||||
if (std::string(PageResult.getValue()).empty())
|
||||
PageResult.setValue(fi.filePath().c_str());
|
||||
|
||||
// open Template file
|
||||
string line;
|
||||
ifstream file (fi.filePath().c_str());
|
||||
|
||||
// make a temp file for FileIncluded Property
|
||||
string tempName = PageResult.getExchangeTempFile();
|
||||
ofstream ofile(tempName.c_str());
|
||||
|
||||
while (!file.eof())
|
||||
{
|
||||
getline (file,line);
|
||||
// check if the marker in the template is found
|
||||
if(line.find("<!-- DrawingContent -->") == string::npos)
|
||||
// if not - write through
|
||||
ofile << line << endl;
|
||||
else
|
||||
{
|
||||
// get through the children and collect all the views
|
||||
const std::vector<App::DocumentObject*> &Grp = Group.getValues();
|
||||
for (std::vector<App::DocumentObject*>::const_iterator It= Grp.begin();It!=Grp.end();++It) {
|
||||
if ((*It)->getTypeId().isDerivedFrom(Drawing::FeatureView::getClassTypeId())) {
|
||||
Drawing::FeatureView *View = dynamic_cast<Drawing::FeatureView *>(*It);
|
||||
ofile << View->ViewResult.getValue();
|
||||
ofile << endl << endl << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
file.close();
|
||||
ofile.close();
|
||||
|
||||
PageResult.setValue(tempName.c_str());
|
||||
|
||||
//const char* text = "lskdfjlsd";
|
||||
//const char* regex = "lskdflds";
|
||||
//boost::regex e(regex);
|
||||
//boost::smatch what;
|
||||
//if(boost::regex_match(string(text), what, e))
|
||||
//{
|
||||
//}
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
72
src/Mod/Drawing/App/FeaturePage.h
Normal file
72
src/Mod/Drawing/App/FeaturePage.h
Normal file
@@ -0,0 +1,72 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) Jürgen Riegel (juergen.riegel@web.de) 2007 *
|
||||
* *
|
||||
* 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 _FeaturePage_h_
|
||||
#define _FeaturePage_h_
|
||||
|
||||
|
||||
#include <App/DocumentObjectGroup.h>
|
||||
#include <App/PropertyStandard.h>
|
||||
#include <App/PropertyFile.h>
|
||||
|
||||
|
||||
namespace Drawing
|
||||
{
|
||||
|
||||
|
||||
/** Base class of all View Features in the drawing module
|
||||
*/
|
||||
class DrawingExport FeaturePage: public App::DocumentObjectGroup
|
||||
{
|
||||
PROPERTY_HEADER(Drawing::FeaturePage);
|
||||
|
||||
public:
|
||||
/// Constructor
|
||||
FeaturePage(void);
|
||||
virtual ~FeaturePage();
|
||||
|
||||
App::PropertyFileIncluded PageResult;
|
||||
App::PropertyFile Template;
|
||||
|
||||
|
||||
/** @name methods overide Feature */
|
||||
//@{
|
||||
/// recalculate the Feature
|
||||
virtual App::DocumentObjectExecReturn *execute(void);
|
||||
//@}
|
||||
|
||||
/// returns the type name of the ViewProvider
|
||||
virtual const char* getViewProviderName(void) const {
|
||||
return "DrawingGui::ViewProviderDrawingPage";
|
||||
}
|
||||
|
||||
protected:
|
||||
void onChanged(const App::Property* prop);
|
||||
};
|
||||
|
||||
|
||||
} //namespace Drawing
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
109
src/Mod/Drawing/App/FeatureProjection.cpp
Normal file
109
src/Mod/Drawing/App/FeatureProjection.cpp
Normal file
@@ -0,0 +1,109 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2009 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 <sstream>
|
||||
# include <BRep_Builder.hxx>
|
||||
# include <TopoDS_Compound.hxx>
|
||||
#endif
|
||||
|
||||
|
||||
#include <strstream>
|
||||
#include <Base/Writer.h>
|
||||
#include <Base/Reader.h>
|
||||
#include <Base/Exception.h>
|
||||
#include <Base/FileInfo.h>
|
||||
|
||||
#include "FeatureProjection.h"
|
||||
#include "ProjectionAlgos.h"
|
||||
|
||||
using namespace Drawing;
|
||||
|
||||
|
||||
PROPERTY_SOURCE(Drawing::FeatureProjection, Part::Feature)
|
||||
|
||||
|
||||
FeatureProjection::FeatureProjection()
|
||||
{
|
||||
static const char *group = "Projection";
|
||||
ADD_PROPERTY_TYPE(Source ,(0),group,App::Prop_None,"Shape to project");
|
||||
ADD_PROPERTY_TYPE(Direction ,(Base::Vector3f(0,0,1)),group,App::Prop_None,"Projection direction");
|
||||
ADD_PROPERTY_TYPE(VCompound ,(true),group,App::Prop_None,"Projection parameter");
|
||||
ADD_PROPERTY_TYPE(Rg1LineVCompound ,(true),group,App::Prop_None,"Projection parameter");
|
||||
ADD_PROPERTY_TYPE(RgNLineVCompound ,(true),group,App::Prop_None,"Projection parameter");
|
||||
ADD_PROPERTY_TYPE(OutLineVCompound ,(true),group,App::Prop_None,"Projection parameter");
|
||||
ADD_PROPERTY_TYPE(IsoLineVCompound ,(true),group,App::Prop_None,"Projection parameter");
|
||||
ADD_PROPERTY_TYPE(HCompound ,(true),group,App::Prop_None,"Projection parameter");
|
||||
ADD_PROPERTY_TYPE(Rg1LineHCompound ,(true),group,App::Prop_None,"Projection parameter");
|
||||
ADD_PROPERTY_TYPE(RgNLineHCompound ,(true),group,App::Prop_None,"Projection parameter");
|
||||
ADD_PROPERTY_TYPE(OutLineHCompound ,(true),group,App::Prop_None,"Projection parameter");
|
||||
ADD_PROPERTY_TYPE(IsoLineHCompound ,(true),group,App::Prop_None,"Projection parameter");
|
||||
}
|
||||
|
||||
FeatureProjection::~FeatureProjection()
|
||||
{
|
||||
}
|
||||
|
||||
App::DocumentObjectExecReturn *FeatureProjection::execute(void)
|
||||
{
|
||||
App::DocumentObject* link = Source.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");
|
||||
const TopoDS_Shape& shape = static_cast<Part::Feature*>(link)->Shape.getShape()._Shape;
|
||||
if (shape.IsNull())
|
||||
return new App::DocumentObjectExecReturn("Linked shape object is empty");
|
||||
|
||||
const Base::Vector3f& dir = Direction.getValue();
|
||||
Drawing::ProjectionAlgos alg(shape, dir);
|
||||
|
||||
TopoDS_Compound comp;
|
||||
BRep_Builder builder;
|
||||
builder.MakeCompound(comp);
|
||||
if (!alg.V.IsNull() && VCompound.getValue())
|
||||
builder.Add(comp, alg.V);
|
||||
if (!alg.V1.IsNull() && Rg1LineVCompound.getValue())
|
||||
builder.Add(comp, alg.V1);
|
||||
if (!alg.VN.IsNull() && RgNLineVCompound.getValue())
|
||||
builder.Add(comp, alg.VN);
|
||||
if (!alg.VO.IsNull() && OutLineVCompound.getValue())
|
||||
builder.Add(comp, alg.VO);
|
||||
if (!alg.VI.IsNull() && IsoLineVCompound.getValue())
|
||||
builder.Add(comp, alg.VI);
|
||||
if (!alg.H.IsNull() && HCompound.getValue())
|
||||
builder.Add(comp, alg.H);
|
||||
if (!alg.H1.IsNull() && Rg1LineHCompound.getValue())
|
||||
builder.Add(comp, alg.H1);
|
||||
if (!alg.HN.IsNull() && RgNLineHCompound.getValue())
|
||||
builder.Add(comp, alg.HN);
|
||||
if (!alg.HO.IsNull() && OutLineHCompound.getValue())
|
||||
builder.Add(comp, alg.HO);
|
||||
if (!alg.HI.IsNull() && IsoLineHCompound.getValue())
|
||||
builder.Add(comp, alg.HI);
|
||||
|
||||
Shape.setValue(comp);
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
73
src/Mod/Drawing/App/FeatureProjection.h
Normal file
73
src/Mod/Drawing/App/FeatureProjection.h
Normal file
@@ -0,0 +1,73 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2009 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 DRAWING_FEATUREPROJECTION
|
||||
#define DRAWING_FEATUREPROJECTION
|
||||
|
||||
|
||||
#include <App/DocumentObject.h>
|
||||
#include <App/PropertyStandard.h>
|
||||
#include <App/PropertyGeo.h>
|
||||
#include <Mod/Part/App/PartFeature.h>
|
||||
|
||||
|
||||
namespace Drawing
|
||||
{
|
||||
|
||||
|
||||
/** Base class of all View Features in the drawing module
|
||||
*/
|
||||
class DrawingExport FeatureProjection : public Part::Feature
|
||||
{
|
||||
PROPERTY_HEADER(Drawing::FeatureProjection);
|
||||
|
||||
public:
|
||||
/// Constructor
|
||||
FeatureProjection();
|
||||
virtual ~FeatureProjection();
|
||||
|
||||
App::PropertyLink Source;
|
||||
App::PropertyVector Direction;
|
||||
App::PropertyBool VCompound;
|
||||
App::PropertyBool Rg1LineVCompound;
|
||||
App::PropertyBool RgNLineVCompound;
|
||||
App::PropertyBool OutLineVCompound;
|
||||
App::PropertyBool IsoLineVCompound;
|
||||
App::PropertyBool HCompound;
|
||||
App::PropertyBool Rg1LineHCompound;
|
||||
App::PropertyBool RgNLineHCompound;
|
||||
App::PropertyBool OutLineHCompound;
|
||||
App::PropertyBool IsoLineHCompound;
|
||||
|
||||
/** @name methods overide feature */
|
||||
//@{
|
||||
/// recalculate the Feature
|
||||
virtual App::DocumentObjectExecReturn *execute(void);
|
||||
//@}
|
||||
};
|
||||
|
||||
} //namespace Drawing
|
||||
|
||||
|
||||
|
||||
#endif // DRAWING_FEATUREPROJECTION
|
||||
84
src/Mod/Drawing/App/FeatureView.cpp
Normal file
84
src/Mod/Drawing/App/FeatureView.cpp
Normal file
@@ -0,0 +1,84 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) Jürgen Riegel (juergen.riegel@web.de) 2002 *
|
||||
* *
|
||||
* 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 <sstream>
|
||||
#endif
|
||||
|
||||
|
||||
#include <strstream>
|
||||
#include <Base/Writer.h>
|
||||
#include <Base/Reader.h>
|
||||
#include <Base/Exception.h>
|
||||
#include <Base/FileInfo.h>
|
||||
|
||||
#include "FeatureView.h"
|
||||
|
||||
using namespace Drawing;
|
||||
|
||||
|
||||
//===========================================================================
|
||||
// FeatureView
|
||||
//===========================================================================
|
||||
|
||||
PROPERTY_SOURCE(Drawing::FeatureView, App::DocumentObject)
|
||||
|
||||
|
||||
|
||||
FeatureView::FeatureView(void)
|
||||
{
|
||||
static const char *group = "Drawing view";
|
||||
ADD_PROPERTY_TYPE(X ,(0),group,App::Prop_None,"X position of the view on the drawing in modeing units (mm)");
|
||||
ADD_PROPERTY_TYPE(Y ,(0),group,App::Prop_None,"Y position of the view on the drawing in modeing units (mm)");
|
||||
ADD_PROPERTY_TYPE(Scale ,(1.0),group,App::Prop_None,"Scale factor of the view");
|
||||
ADD_PROPERTY_TYPE(Rotation ,(0),group,App::Prop_None,"Rotation of the view in degres counterclockwise");
|
||||
|
||||
App::PropertyType type = (App::PropertyType)(App::Prop_Hidden);
|
||||
ADD_PROPERTY_TYPE(ViewResult ,(0),group,type,"Resulting SVG fragment of that view");
|
||||
}
|
||||
|
||||
FeatureView::~FeatureView()
|
||||
{
|
||||
}
|
||||
|
||||
App::DocumentObjectExecReturn *FeatureView::execute(void)
|
||||
{
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
|
||||
|
||||
// Python Drawing feature ---------------------------------------------------------
|
||||
|
||||
namespace App {
|
||||
/// @cond DOXERR
|
||||
PROPERTY_SOURCE_TEMPLATE(Drawing::FeatureViewPython, Drawing::FeatureView)
|
||||
template<> const char* Drawing::FeatureViewPython::getViewProviderName(void) const {
|
||||
return "DrawingGui::ViewProviderDrawingView";
|
||||
}
|
||||
/// @endcond
|
||||
|
||||
// explicit template instantiation
|
||||
template class DrawingExport FeaturePythonT<Drawing::FeatureView>;
|
||||
}
|
||||
73
src/Mod/Drawing/App/FeatureView.h
Normal file
73
src/Mod/Drawing/App/FeatureView.h
Normal file
@@ -0,0 +1,73 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) Jürgen Riegel (juergen.riegel@web.de) 2007 *
|
||||
* *
|
||||
* 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 _FeatureView_h_
|
||||
#define _FeatureView_h_
|
||||
|
||||
|
||||
#include <App/DocumentObject.h>
|
||||
#include <App/PropertyStandard.h>
|
||||
#include <App/PropertyGeo.h>
|
||||
#include <App/FeaturePython.h>
|
||||
|
||||
|
||||
namespace Drawing
|
||||
{
|
||||
|
||||
|
||||
/** Base class of all View Features in the drawing module
|
||||
*/
|
||||
class DrawingExport FeatureView : public App::DocumentObject
|
||||
{
|
||||
PROPERTY_HEADER(Drawing::FeatureView);
|
||||
|
||||
public:
|
||||
/// Constructor
|
||||
FeatureView(void);
|
||||
virtual ~FeatureView();
|
||||
|
||||
App::PropertyFloat X,Y,Scale,Rotation;
|
||||
App::PropertyString ViewResult;
|
||||
|
||||
|
||||
/** @name methods overide Feature */
|
||||
//@{
|
||||
/// recalculate the Feature
|
||||
virtual App::DocumentObjectExecReturn *execute(void);
|
||||
//@}
|
||||
|
||||
/// returns the type name of the ViewProvider
|
||||
virtual const char* getViewProviderName(void) const {
|
||||
return "DrawingGui::ViewProviderDrawingView";
|
||||
}
|
||||
};
|
||||
|
||||
typedef App::FeaturePythonT<FeatureView> FeatureViewPython;
|
||||
|
||||
} //namespace Drawing
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
229
src/Mod/Drawing/App/FeatureViewPart.cpp
Normal file
229
src/Mod/Drawing/App/FeatureViewPart.cpp
Normal file
@@ -0,0 +1,229 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) Jürgen Riegel (juergen.riegel@web.de) 2002 *
|
||||
* *
|
||||
* 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 <sstream>
|
||||
#endif
|
||||
|
||||
|
||||
#include <HLRBRep_Algo.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <HLRTopoBRep_OutLiner.hxx>
|
||||
//#include <BRepAPI_MakeOutLine.hxx>
|
||||
#include <HLRAlgo_Projector.hxx>
|
||||
#include <HLRBRep_ShapeBounds.hxx>
|
||||
#include <HLRBRep_HLRToShape.hxx>
|
||||
#include <gp_Ax2.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Dir.hxx>
|
||||
#include <Poly_Polygon3D.hxx>
|
||||
#include <Poly_Triangulation.hxx>
|
||||
#include <Poly_PolygonOnTriangulation.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopoDS_Face.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <TopoDS_Vertex.hxx>
|
||||
#include <TopExp.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
#include <TopTools_IndexedMapOfShape.hxx>
|
||||
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
|
||||
#include <TopTools_ListOfShape.hxx>
|
||||
#include <TColgp_Array1OfPnt2d.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <BRepMesh.hxx>
|
||||
|
||||
|
||||
#include <Base/Exception.h>
|
||||
#include <Base/FileInfo.h>
|
||||
#include <Mod/Part/App/PartFeature.h>
|
||||
|
||||
#include "FeatureViewPart.h"
|
||||
#include "ProjectionAlgos.h"
|
||||
|
||||
using namespace Drawing;
|
||||
using namespace std;
|
||||
|
||||
|
||||
//===========================================================================
|
||||
// FeatureViewPart
|
||||
//===========================================================================
|
||||
|
||||
PROPERTY_SOURCE(Drawing::FeatureViewPart, Drawing::FeatureView)
|
||||
|
||||
|
||||
FeatureViewPart::FeatureViewPart(void)
|
||||
{
|
||||
static const char *group = "Shape view";
|
||||
|
||||
ADD_PROPERTY_TYPE(Direction ,(0,0,1.0),group,App::Prop_None,"Projection direction");
|
||||
ADD_PROPERTY_TYPE(Source ,(0),group,App::Prop_None,"Shape to view");
|
||||
ADD_PROPERTY_TYPE(ShowHiddenLines ,(false),group,App::Prop_None,"Control the appearance of the dashed hidden lines");
|
||||
ADD_PROPERTY_TYPE(ShowSmoothLines ,(false),group,App::Prop_None,"Control the appearance of the smooth lines");
|
||||
}
|
||||
|
||||
FeatureViewPart::~FeatureViewPart()
|
||||
{
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
App::DocumentObjectExecReturn *FeatureViewPart::execute(void)
|
||||
{
|
||||
std::stringstream result;
|
||||
std::string ViewName = Label.getValue();
|
||||
|
||||
App::DocumentObject* link = Source.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");
|
||||
TopoDS_Shape shape = static_cast<Part::Feature*>(link)->Shape.getShape()._Shape;
|
||||
if (shape.IsNull())
|
||||
return new App::DocumentObjectExecReturn("Linked shape object is empty");
|
||||
|
||||
Handle( HLRBRep_Algo ) brep_hlr = new HLRBRep_Algo;
|
||||
brep_hlr->Add( shape );
|
||||
|
||||
gp_Ax2 transform(gp_Pnt(0,0,0),gp_Dir(0,0,1));
|
||||
HLRAlgo_Projector projector( transform );
|
||||
brep_hlr->Projector( projector );
|
||||
brep_hlr->Update();
|
||||
brep_hlr->Hide();
|
||||
|
||||
// extracting the result sets:
|
||||
HLRBRep_HLRToShape shapes( brep_hlr );
|
||||
|
||||
TopoDS_Shape VisiblyEdges;
|
||||
VisiblyEdges = shapes.VCompound();
|
||||
|
||||
TopoDS_Shape HiddenEdges;
|
||||
HiddenEdges = shapes.HCompound();
|
||||
|
||||
BRepMesh::Mesh(VisiblyEdges,0.1);
|
||||
//HLRBRep_HLRToShape Tool(Hider);
|
||||
//TopoDS_Shape V = Tool.VCompound ();// artes vives vues
|
||||
//TopoDS_Shape V1 = Tool.Rg1LineVCompound();// artes rgulires vues
|
||||
//TopoDS_Shape VN = Tool.RgNLineVCompound();// artes de couture vues
|
||||
//TopoDS_Shape VO = Tool.OutLineVCompound();// contours apparents vus
|
||||
//TopoDS_Shape VI = Tool.IsoLineVCompound();// isoparamtriques vues
|
||||
//TopoDS_Shape H = Tool.HCompound ();// artes vives caches
|
||||
//TopoDS_Shape H1 = Tool.Rg1LineHCompound();// artes rgulires caches
|
||||
//TopoDS_Shape HN = Tool.RgNLineHCompound();// artes de couture caches
|
||||
//TopoDS_Shape HO = Tool.OutLineHCompound();// contours apparents cachs
|
||||
//TopoDS_Shape HI = Tool.IsoLineHCompound();// isoparamtriques caches
|
||||
|
||||
result << "<g"
|
||||
<< " id=\"" << ViewName << "\"" << endl
|
||||
<< " stroke=\"rgb(0, 0, 0)\"" << endl
|
||||
<< " stroke-width=\"0.35\"" << endl
|
||||
<< " stroke-linecap=\"butt\"" << endl
|
||||
<< " stroke-linejoin=\"miter\"" << endl
|
||||
<< " transform=\"translate("<< X.getValue()<<","<<Y.getValue()<<") scale("<< Scale.getValue()<<","<<Scale.getValue()<<")\"" << endl
|
||||
<< " fill=\"none\"" << endl
|
||||
<< " >" << endl;
|
||||
|
||||
TopExp_Explorer edges( VisiblyEdges, TopAbs_EDGE );
|
||||
for (int i = 1 ; edges.More(); edges.Next(),i++ ) {
|
||||
TopoDS_Edge edge = TopoDS::Edge( edges.Current() );
|
||||
TopLoc_Location location;
|
||||
Handle( Poly_Polygon3D ) polygon = BRep_Tool::Polygon3D( edge, location );
|
||||
if ( !polygon.IsNull() ) {
|
||||
const TColgp_Array1OfPnt& nodes = polygon->Nodes();
|
||||
char c = 'M';
|
||||
result << "<path id= \"" << ViewName << i << "\" d=\" ";
|
||||
for ( int i = nodes.Lower(); i<= nodes.Upper(); i++ ){
|
||||
result << c << " " << nodes(i).X() << " " << nodes(i).Y()<< " " ;
|
||||
c = 'L';
|
||||
}
|
||||
result << "\" />" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
result << "</g>" << endl;
|
||||
|
||||
// Apply the resulting fragment
|
||||
ViewResult.setValue(result.str().c_str());
|
||||
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
#else
|
||||
App::DocumentObjectExecReturn *FeatureViewPart::execute(void)
|
||||
{
|
||||
std::stringstream result;
|
||||
std::string ViewName = Label.getValue();
|
||||
|
||||
App::DocumentObject* link = Source.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");
|
||||
TopoDS_Shape shape = static_cast<Part::Feature*>(link)->Shape.getShape()._Shape;
|
||||
if (shape.IsNull())
|
||||
return new App::DocumentObjectExecReturn("Linked shape object is empty");
|
||||
Base::Vector3f Dir = Direction.getValue();
|
||||
bool hidden = ShowHiddenLines.getValue();
|
||||
bool smooth = ShowSmoothLines.getValue();
|
||||
|
||||
try {
|
||||
ProjectionAlgos Alg(ProjectionAlgos::invertY(shape),Dir);
|
||||
result << "<g"
|
||||
<< " id=\"" << ViewName << "\"" << endl
|
||||
<< " transform=\"rotate("<< Rotation.getValue() << ","<< X.getValue()<<","<<Y.getValue()<<") translate("<< X.getValue()<<","<<Y.getValue()<<") scale("<< Scale.getValue()<<","<<Scale.getValue()<<")\"" << endl
|
||||
<< " >" << endl;
|
||||
|
||||
ProjectionAlgos::SvgExtractionType type = ProjectionAlgos::Plain;
|
||||
if (hidden) type = (ProjectionAlgos::SvgExtractionType)(type|ProjectionAlgos::WithHidden);
|
||||
if (smooth) type = (ProjectionAlgos::SvgExtractionType)(type|ProjectionAlgos::WithSmooth);
|
||||
result << Alg.getSVG(type, this->Scale.getValue());
|
||||
|
||||
result << "</g>" << endl;
|
||||
|
||||
// Apply the resulting fragment
|
||||
ViewResult.setValue(result.str().c_str());
|
||||
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
return new App::DocumentObjectExecReturn(e->GetMessageString());
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
// Python Drawing feature ---------------------------------------------------------
|
||||
|
||||
namespace App {
|
||||
/// @cond DOXERR
|
||||
PROPERTY_SOURCE_TEMPLATE(Drawing::FeatureViewPartPython, Drawing::FeatureViewPart)
|
||||
template<> const char* Drawing::FeatureViewPartPython::getViewProviderName(void) const {
|
||||
return "DrawingGui::ViewProviderDrawingView";
|
||||
}
|
||||
/// @endcond
|
||||
|
||||
// explicit template instantiation
|
||||
template class DrawingExport FeaturePythonT<Drawing::FeatureViewPart>;
|
||||
}
|
||||
75
src/Mod/Drawing/App/FeatureViewPart.h
Normal file
75
src/Mod/Drawing/App/FeatureViewPart.h
Normal file
@@ -0,0 +1,75 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) Jürgen Riegel (juergen.riegel@web.de) 2007 *
|
||||
* *
|
||||
* 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 _FeatureViewPart_h_
|
||||
#define _FeatureViewPart_h_
|
||||
|
||||
|
||||
#include <App/DocumentObject.h>
|
||||
#include <App/PropertyLinks.h>
|
||||
#include "FeatureView.h"
|
||||
#include <App/FeaturePython.h>
|
||||
|
||||
|
||||
namespace Drawing
|
||||
{
|
||||
|
||||
|
||||
/** Base class of all View Features in the drawing module
|
||||
*/
|
||||
class DrawingExport FeatureViewPart : public FeatureView
|
||||
{
|
||||
PROPERTY_HEADER(Part::FeatureViewPart);
|
||||
|
||||
public:
|
||||
/// Constructor
|
||||
FeatureViewPart(void);
|
||||
virtual ~FeatureViewPart();
|
||||
|
||||
App::PropertyLink Source;
|
||||
App::PropertyVector Direction;
|
||||
App::PropertyBool ShowHiddenLines;
|
||||
App::PropertyBool ShowSmoothLines;
|
||||
|
||||
|
||||
/** @name methods overide Feature */
|
||||
//@{
|
||||
/// recalculate the Feature
|
||||
virtual App::DocumentObjectExecReturn *execute(void);
|
||||
//@}
|
||||
|
||||
/// returns the type name of the ViewProvider
|
||||
virtual const char* getViewProviderName(void) const {
|
||||
return "DrawingGui::ViewProviderDrawingView";
|
||||
}
|
||||
};
|
||||
|
||||
typedef App::FeaturePythonT<FeatureViewPart> FeatureViewPartPython;
|
||||
|
||||
|
||||
} //namespace Drawing
|
||||
|
||||
|
||||
#endif
|
||||
80
src/Mod/Drawing/App/Makefile.am
Normal file
80
src/Mod/Drawing/App/Makefile.am
Normal file
@@ -0,0 +1,80 @@
|
||||
|
||||
lib_LTLIBRARIES=libDrawing.la Drawing.la
|
||||
|
||||
libDrawing_la_SOURCES=\
|
||||
AppDrawingPy.cpp \
|
||||
FeaturePage.cpp \
|
||||
FeaturePage.h \
|
||||
FeatureProjection.cpp \
|
||||
FeatureProjection.h \
|
||||
FeatureView.cpp \
|
||||
FeatureView.h \
|
||||
FeatureViewPart.cpp \
|
||||
FeatureViewPart.h \
|
||||
PageGroup.cpp \
|
||||
PageGroup.h \
|
||||
ProjectionAlgos.cpp \
|
||||
ProjectionAlgos.h \
|
||||
PreCompiled.cpp \
|
||||
PreCompiled.h
|
||||
|
||||
|
||||
# the library search path.
|
||||
libDrawing_la_LDFLAGS = -L../../../Base -L../../../App -L../../../Mod/Part/App \
|
||||
-L$(OCC_LIB) $(all_libraries) \
|
||||
-version-info @LIB_CURRENT@:@LIB_REVISION@:@LIB_AGE@
|
||||
libDrawing_la_CPPFLAGS = -DDrawingExport=
|
||||
|
||||
libDrawing_la_LIBADD = \
|
||||
@BOOST_REGEX_LIB@ @BOOST_SYSTEM_LIB@ \
|
||||
-l@PYTHON_LIB@ \
|
||||
-lxerces-c \
|
||||
-lFreeCADBase \
|
||||
-lFreeCADApp \
|
||||
-lPart \
|
||||
-lTKernel \
|
||||
-lTKG2d \
|
||||
-lTKG3d \
|
||||
-lTKMath \
|
||||
-lTKSTEP \
|
||||
-lTKIGES \
|
||||
-lTKSTL \
|
||||
-lTKShHealing \
|
||||
-lTKXSBase \
|
||||
-lTKBool \
|
||||
-lTKBO \
|
||||
-lTKBRep \
|
||||
-lTKTopAlgo \
|
||||
-lTKGeomAlgo \
|
||||
-lTKGeomBase \
|
||||
-lTKOffset \
|
||||
-lTKPrim \
|
||||
-lTKHLR \
|
||||
-lTKMesh
|
||||
|
||||
#--------------------------------------------------------------------------------------
|
||||
# Loader of libDrawing
|
||||
|
||||
Drawing_la_SOURCES=\
|
||||
AppDrawing.cpp
|
||||
|
||||
# the library search path.
|
||||
Drawing_la_LDFLAGS = $(libDrawing_la_LDFLAGS) -module -avoid-version
|
||||
Drawing_la_CPPFLAGS = $(libDrawing_la_CPPFLAGS)
|
||||
|
||||
Drawing_la_LIBADD = \
|
||||
$(libDrawing_la_LIBADD) \
|
||||
-lDrawing
|
||||
|
||||
Drawing_la_DEPENDENCIES = libDrawing.la
|
||||
|
||||
#--------------------------------------------------------------------------------------
|
||||
|
||||
# set the include path found by configure
|
||||
AM_CXXFLAGS = -I$(top_srcdir)/src -I$(top_builddir)/src -I$(OCC_INC) $(all_includes)
|
||||
|
||||
|
||||
libdir = $(prefix)/Mod/Drawing
|
||||
|
||||
EXTRA_DIST = \
|
||||
CMakeLists.txt
|
||||
49
src/Mod/Drawing/App/PageGroup.cpp
Normal file
49
src/Mod/Drawing/App/PageGroup.cpp
Normal file
@@ -0,0 +1,49 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) Jürgen Riegel (juergen.riegel@web.de) 2002 *
|
||||
* *
|
||||
* 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 <sstream>
|
||||
#endif
|
||||
|
||||
#include "PageGroup.h"
|
||||
|
||||
using namespace Drawing;
|
||||
|
||||
|
||||
//===========================================================================
|
||||
// PageGroup
|
||||
//===========================================================================
|
||||
|
||||
PROPERTY_SOURCE(Drawing::PageGroup, App::DocumentObjectGroup)
|
||||
|
||||
PageGroup::PageGroup(void)
|
||||
{
|
||||
static const char *group = "Drawings";
|
||||
ADD_PROPERTY_TYPE(Pages,(0),group,App::Prop_None,"List of pages");
|
||||
}
|
||||
|
||||
PageGroup::~PageGroup()
|
||||
{
|
||||
}
|
||||
63
src/Mod/Drawing/App/PageGroup.h
Normal file
63
src/Mod/Drawing/App/PageGroup.h
Normal file
@@ -0,0 +1,63 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) Jürgen Riegel (juergen.riegel@web.de) 2007 *
|
||||
* *
|
||||
* 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 _PageGroup_h_
|
||||
#define _PageGroup_h_
|
||||
|
||||
|
||||
#include <App/DocumentObjectGroup.h>
|
||||
#include <App/PropertyStandard.h>
|
||||
#include <App/PropertyLinks.h>
|
||||
|
||||
|
||||
namespace Drawing
|
||||
{
|
||||
|
||||
|
||||
/** Base class of all View Features in the drawing module
|
||||
*/
|
||||
class DrawingExport PageGroup : public App::DocumentObjectGroup
|
||||
{
|
||||
PROPERTY_HEADER(Drawing::PageGroup);
|
||||
|
||||
public:
|
||||
/// Constructor
|
||||
PageGroup(void);
|
||||
virtual ~PageGroup();
|
||||
|
||||
App::PropertyLinkList Pages;
|
||||
|
||||
/// returns the type name of the ViewProvider
|
||||
virtual const char* getViewProviderName(void) const {
|
||||
return "DrawingGui::ViewProviderDrawing";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} //namespace Drawing
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
23
src/Mod/Drawing/App/PreCompiled.cpp
Normal file
23
src/Mod/Drawing/App/PreCompiled.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) Jürgen Riegel (juergen.riegel@web.de) 2007 *
|
||||
* *
|
||||
* 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"
|
||||
234
src/Mod/Drawing/App/PreCompiled.h
Normal file
234
src/Mod/Drawing/App/PreCompiled.h
Normal file
@@ -0,0 +1,234 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) Jürgen Riegel (juergen.riegel@web.de) 2007 *
|
||||
* *
|
||||
* 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 DRAWING_PRECOMPILED_H
|
||||
#define DRAWING_PRECOMPILED_H
|
||||
|
||||
#include <FCConfig.h>
|
||||
|
||||
// Exporting of App classes
|
||||
#ifdef FC_OS_WIN32
|
||||
# define DrawingExport __declspec(dllexport)
|
||||
# define PartExport __declspec(dllimport)
|
||||
# define MeshExport __declspec(dllimport)
|
||||
#else // for Linux
|
||||
# define DrawingExport
|
||||
# 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 =====================================================================================
|
||||
// Base
|
||||
#include <Standard_Failure.hxx>
|
||||
#include <Standard_GUID.hxx>
|
||||
#include <Standard_AbortiveTransaction.hxx>
|
||||
#include <Standard_Address.hxx>
|
||||
#include <Standard_AncestorIterator.hxx>
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <Standard_Byte.hxx>
|
||||
#include <Standard_Character.hxx>
|
||||
#include <Standard_ConstructionError.hxx>
|
||||
#include <Standard_CString.hxx>
|
||||
#include <Standard_ctype.hxx>
|
||||
#include <Standard_DefineHandle.hxx>
|
||||
#include <Standard_DimensionError.hxx>
|
||||
#include <Standard_DimensionMismatch.hxx>
|
||||
#include <Standard_DivideByZero.hxx>
|
||||
#include <Standard_DomainError.hxx>
|
||||
#include <Standard_ErrorHandler.hxx>
|
||||
#include <Standard_ExtCharacter.hxx>
|
||||
#include <Standard_ExtString.hxx>
|
||||
#include <Standard_Failure.hxx>
|
||||
#include <Standard_GUID.hxx>
|
||||
#include <Standard_ImmutableObject.hxx>
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <Standard_InternalType.hxx>
|
||||
#include <Standard_IStream.hxx>
|
||||
#include <Standard_KindOfType.hxx>
|
||||
#include <Standard_LicenseError.hxx>
|
||||
#include <Standard_LicenseNotFound.hxx>
|
||||
#include <Standard_Macro.hxx>
|
||||
#include <Standard_math.hxx>
|
||||
#include <Standard_MultiplyDefined.hxx>
|
||||
#include <Standard_NegativeValue.hxx>
|
||||
#include <Standard_NoMoreObject.hxx>
|
||||
#include <Standard_NoSuchObject.hxx>
|
||||
#include <Standard_NotImplemented.hxx>
|
||||
#include <Standard_NullObject.hxx>
|
||||
#include <Standard_NullValue.hxx>
|
||||
#include <Standard_NumericError.hxx>
|
||||
#include <Standard_OId.hxx>
|
||||
#include <Standard_OStream.hxx>
|
||||
#include <Standard_OutOfMemory.hxx>
|
||||
#include <Standard_OutOfRange.hxx>
|
||||
#include <Standard_Overflow.hxx>
|
||||
#include <Standard_Persistent.hxx>
|
||||
#include <Standard_Persistent_proto.hxx>
|
||||
#include <Standard_PrimitiveTypes.hxx>
|
||||
#include <Standard_ProgramError.hxx>
|
||||
#include <Standard_RangeError.hxx>
|
||||
#include <Standard_Real.hxx>
|
||||
#include <Standard_ShortReal.hxx>
|
||||
#include <Standard_SStream.hxx>
|
||||
#include <Standard_Static.hxx>
|
||||
#include <Standard_Storable.hxx>
|
||||
#include <Standard_Stream.hxx>
|
||||
#include <Standard_String.hxx>
|
||||
#include <Standard_TooManyUsers.hxx>
|
||||
#include <Standard_Transient.hxx>
|
||||
#include <Standard_Transient_proto.hxx>
|
||||
#include <Standard_Type.hxx>
|
||||
#include <Standard_TypeDef.hxx>
|
||||
#include <Standard_TypeMismatch.hxx>
|
||||
#include <Standard_Underflow.hxx>
|
||||
#include <Standard_UUID.hxx>
|
||||
#include <Standard_WayOfLife.hxx>
|
||||
|
||||
|
||||
#include <TCollection_ExtendedString.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <TColStd_SequenceOfExtendedString.hxx>
|
||||
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <BRepAdaptor_Curve.hxx>
|
||||
#include <BRepAdaptor_Surface.hxx>
|
||||
#include <BRepBuilderAPI.hxx>
|
||||
#include <BRepBuilderAPI_MakeEdge.hxx>
|
||||
#include <BRepBuilderAPI_MakePolygon.hxx>
|
||||
#include <BRepTools.hxx>
|
||||
#include <BRepTools_ShapeSet.hxx>
|
||||
#include <BRepBuilderAPI_Copy.hxx>
|
||||
#include <BRepCheck_Analyzer.hxx>
|
||||
#include <BRepCheck_Result.hxx>
|
||||
#include <BRepCheck_ListIteratorOfListOfStatus.hxx>
|
||||
|
||||
#include <BRepTools.hxx>
|
||||
#include <Standard_DefineHandle.hxx>
|
||||
#include <GCE2d_MakeSegment.hxx>
|
||||
#include <GCPnts_TangentialDeflection.hxx>
|
||||
#include <Geom_Axis2Placement.hxx>
|
||||
#include <Geom_CartesianPoint.hxx>
|
||||
#include <Geom_Line.hxx>
|
||||
#include <Geom_Surface.hxx>
|
||||
#include <Geom2d_BezierCurve.hxx>
|
||||
#include <Geom2d_BSplineCurve.hxx>
|
||||
#include <Geom2d_Curve.hxx>
|
||||
#include <Geom2d_TrimmedCurve.hxx>
|
||||
#include <Geom2dAdaptor_Curve.hxx>
|
||||
#include <GeomAbs_CurveType.hxx>
|
||||
#include <GeomAdaptor_Curve.hxx>
|
||||
#include <Geom_BezierCurve.hxx>
|
||||
#include <Geom_BezierSurface.hxx>
|
||||
#include <Geom_BSplineCurve.hxx>
|
||||
#include <Geom_BSplineSurface.hxx>
|
||||
#include <Geom_Circle.hxx>
|
||||
#include <Geom_ConicalSurface.hxx>
|
||||
#include <Geom_CylindricalSurface.hxx>
|
||||
#include <Geom_Ellipse.hxx>
|
||||
#include <Geom_Hyperbola.hxx>
|
||||
#include <Geom_SphericalSurface.hxx>
|
||||
#include <Geom_SurfaceOfLinearExtrusion.hxx>
|
||||
#include <Geom_SurfaceOfRevolution.hxx>
|
||||
#include <Geom_Parabola.hxx>
|
||||
#include <Geom_Plane.hxx>
|
||||
#include <Geom_ToroidalSurface.hxx>
|
||||
#include <GeomTools_Curve2dSet.hxx>
|
||||
#include <gp_Ax2d.hxx>
|
||||
#include <gp_Circ.hxx>
|
||||
#include <gp_Circ2d.hxx>
|
||||
#include <gp_Cone.hxx>
|
||||
#include <gp_Cylinder.hxx>
|
||||
#include <gp_Dir2d.hxx>
|
||||
#include <gp_Elips.hxx>
|
||||
#include <gp_Hypr.hxx>
|
||||
#include <gp_Lin2d.hxx>
|
||||
#include <gp_Lin.hxx>
|
||||
#include <gp_Parab.hxx>
|
||||
#include <gp_Pnt2d.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Pln.hxx>
|
||||
#include <gp_Sphere.hxx>
|
||||
#include <gp_Torus.hxx>
|
||||
#include <gp_Vec.hxx>
|
||||
#include <gp_Vec2d.hxx>
|
||||
#include <MMgt_TShared.hxx>
|
||||
#include <Precision.hxx>
|
||||
#include <Quantity_Factor.hxx>
|
||||
#include <Quantity_Length.hxx>
|
||||
#include <Quantity_NameOfColor.hxx>
|
||||
#include <Quantity_PhysicalQuantity.hxx>
|
||||
#include <Quantity_PlaneAngle.hxx>
|
||||
#include <Quantity_TypeOfColor.hxx>
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <Standard_CString.hxx>
|
||||
#include <Standard_ErrorHandler.hxx>
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <Standard_IStream.hxx>
|
||||
#include <Standard_Macro.hxx>
|
||||
#include <Standard_NotImplemented.hxx>
|
||||
#include <Standard_OStream.hxx>
|
||||
#include <Standard_Real.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <TColgp_Array1OfPnt2d.hxx>
|
||||
#include <TColgp_HArray1OfPnt2d.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <TColStd_HSequenceOfTransient.hxx>
|
||||
#include <TColStd_MapIteratorOfMapOfTransient.hxx>
|
||||
#include <TColStd_MapOfTransient.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopoDS_Compound.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <TopoDS_Iterator.hxx>
|
||||
#include <TopoDS_ListIteratorOfListOfShape.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <TopoDS_Solid.hxx>
|
||||
#include <TopoDS_Vertex.hxx>
|
||||
#include <TopExp.hxx>
|
||||
#include <TopTools_ListIteratorOfListOfShape.hxx>
|
||||
#include <TopTools_HSequenceOfShape.hxx>
|
||||
#include <TopTools_MapOfShape.hxx>
|
||||
#include <UnitsAPI.hxx>
|
||||
#include <BRepPrimAPI_MakeBox.hxx>
|
||||
#include <BRepPrimAPI_MakeCylinder.hxx>
|
||||
|
||||
#include <Python.h>
|
||||
|
||||
|
||||
#endif // _PreComp_
|
||||
#endif
|
||||
|
||||
419
src/Mod/Drawing/App/ProjectionAlgos.cpp
Normal file
419
src/Mod/Drawing/App/ProjectionAlgos.cpp
Normal file
@@ -0,0 +1,419 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) Jürgen Riegel (juergen.riegel@web.de) 2002 *
|
||||
* *
|
||||
* 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 <sstream>
|
||||
# include <BRepAdaptor_Curve.hxx>
|
||||
# include <Geom_Circle.hxx>
|
||||
# include <gp_Circ.hxx>
|
||||
# include <gp_Elips.hxx>
|
||||
#endif
|
||||
|
||||
#include <Bnd_Box.hxx>
|
||||
#include <BRepBndLib.hxx>
|
||||
#include <BRepBuilderAPI_Transform.hxx>
|
||||
#include <HLRBRep_Algo.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <HLRTopoBRep_OutLiner.hxx>
|
||||
//#include <BRepAPI_MakeOutLine.hxx>
|
||||
#include <HLRAlgo_Projector.hxx>
|
||||
#include <HLRBRep_ShapeBounds.hxx>
|
||||
#include <HLRBRep_HLRToShape.hxx>
|
||||
#include <gp_Ax2.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Dir.hxx>
|
||||
#include <gp_Vec.hxx>
|
||||
#include <Poly_Polygon3D.hxx>
|
||||
#include <Poly_Triangulation.hxx>
|
||||
#include <Poly_PolygonOnTriangulation.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopoDS_Face.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <TopoDS_Vertex.hxx>
|
||||
#include <TopExp.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
#include <TopTools_IndexedMapOfShape.hxx>
|
||||
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
|
||||
#include <TopTools_ListOfShape.hxx>
|
||||
#include <TColgp_Array1OfPnt2d.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <BRepMesh.hxx>
|
||||
|
||||
#include <BRepAdaptor_CompCurve.hxx>
|
||||
#include <Handle_BRepAdaptor_HCompCurve.hxx>
|
||||
#include <Approx_Curve3d.hxx>
|
||||
#include <BRepAdaptor_HCurve.hxx>
|
||||
#include <Handle_BRepAdaptor_HCurve.hxx>
|
||||
#include <Geom_BSplineCurve.hxx>
|
||||
#include <Handle_Geom_BSplineCurve.hxx>
|
||||
#include <Geom_BezierCurve.hxx>
|
||||
#include <GeomConvert_BSplineCurveToBezierCurve.hxx>
|
||||
|
||||
|
||||
#include <Base/Exception.h>
|
||||
#include <Base/FileInfo.h>
|
||||
#include <Base/Tools.h>
|
||||
#include <Mod/Part/App/PartFeature.h>
|
||||
|
||||
#include "ProjectionAlgos.h"
|
||||
|
||||
using namespace Drawing;
|
||||
using namespace std;
|
||||
|
||||
|
||||
//===========================================================================
|
||||
// ProjectionAlgos
|
||||
//===========================================================================
|
||||
|
||||
|
||||
|
||||
ProjectionAlgos::ProjectionAlgos(const TopoDS_Shape &Input, const Base::Vector3f &Dir)
|
||||
: Input(Input), Direction(Dir)
|
||||
{
|
||||
execute();
|
||||
}
|
||||
|
||||
ProjectionAlgos::~ProjectionAlgos()
|
||||
{
|
||||
}
|
||||
|
||||
TopoDS_Shape ProjectionAlgos::invertY(const TopoDS_Shape& shape)
|
||||
{
|
||||
// make sure to have the y coordinates inverted
|
||||
gp_Trsf mat;
|
||||
Bnd_Box bounds;
|
||||
BRepBndLib::Add(shape, bounds);
|
||||
bounds.SetGap(0.0);
|
||||
Standard_Real xMin, yMin, zMin, xMax, yMax, zMax;
|
||||
bounds.Get(xMin, yMin, zMin, xMax, yMax, zMax);
|
||||
mat.SetMirror(gp_Ax2(gp_Pnt((xMin+xMax)/2,(yMin+yMax)/2,(zMin+zMax)/2), gp_Dir(0,1,0)));
|
||||
BRepBuilderAPI_Transform mkTrf(shape, mat);
|
||||
return mkTrf.Shape();
|
||||
}
|
||||
|
||||
void ProjectionAlgos::execute(void)
|
||||
{
|
||||
Handle( HLRBRep_Algo ) brep_hlr = new HLRBRep_Algo;
|
||||
brep_hlr->Add(Input);
|
||||
|
||||
gp_Ax2 transform(gp_Pnt(0,0,0),gp_Dir(Direction.x,Direction.y,Direction.z));
|
||||
HLRAlgo_Projector projector( transform );
|
||||
brep_hlr->Projector(projector);
|
||||
brep_hlr->Update();
|
||||
brep_hlr->Hide();
|
||||
|
||||
// extracting the result sets:
|
||||
HLRBRep_HLRToShape shapes( brep_hlr );
|
||||
|
||||
V = shapes.VCompound ();// hard edge visibly
|
||||
V1 = shapes.Rg1LineVCompound();// Smoth edges visibly
|
||||
VN = shapes.RgNLineVCompound();// contour edges visibly
|
||||
VO = shapes.OutLineVCompound();// contours apparents visibly
|
||||
VI = shapes.IsoLineVCompound();// isoparamtriques visibly
|
||||
H = shapes.HCompound ();// hard edge invisibly
|
||||
H1 = shapes.Rg1LineHCompound();// Smoth edges invisibly
|
||||
HN = shapes.RgNLineHCompound();// contour edges invisibly
|
||||
HO = shapes.OutLineHCompound();// contours apparents invisibly
|
||||
HI = shapes.IsoLineHCompound();// isoparamtriques invisibly
|
||||
|
||||
}
|
||||
|
||||
std::string ProjectionAlgos::getSVG(SvgExtractionType type, float scale)
|
||||
{
|
||||
std::stringstream result;
|
||||
if (!H.IsNull() && (type & WithHidden)) {
|
||||
float width = 0.15f/scale;
|
||||
BRepMesh::Mesh(H,0.1);
|
||||
result << "<g"
|
||||
//<< " id=\"" << ViewName << "\"" << endl
|
||||
<< " stroke=\"rgb(0, 0, 0)\"" << endl
|
||||
<< " stroke-width=\"" << width << "\"" << endl
|
||||
<< " stroke-linecap=\"butt\"" << endl
|
||||
<< " stroke-linejoin=\"miter\"" << endl
|
||||
<< " stroke-dasharray=\"5 3\"" << endl
|
||||
<< " fill=\"none\"" << endl
|
||||
<< " >" << endl
|
||||
<< Edges2SVG(H)
|
||||
<< "</g>" << endl;
|
||||
}
|
||||
if (!HO.IsNull() && (type & WithHidden)) {
|
||||
float width = 0.15f/scale;
|
||||
BRepMesh::Mesh(HO,0.1);
|
||||
result << "<g"
|
||||
//<< " id=\"" << ViewName << "\"" << endl
|
||||
<< " stroke=\"rgb(0, 0, 0)\"" << endl
|
||||
<< " stroke-width=\"" << width << "\"" << endl
|
||||
<< " stroke-linecap=\"butt\"" << endl
|
||||
<< " stroke-linejoin=\"miter\"" << endl
|
||||
<< " stroke-dasharray=\"5 3\"" << endl
|
||||
<< " fill=\"none\"" << endl
|
||||
<< " >" << endl
|
||||
<< Edges2SVG(HO)
|
||||
<< "</g>" << endl;
|
||||
}
|
||||
if (!VO.IsNull()) {
|
||||
float width = 0.35f/scale;
|
||||
BRepMesh::Mesh(VO,0.1);
|
||||
result << "<g"
|
||||
//<< " id=\"" << ViewName << "\"" << endl
|
||||
<< " stroke=\"rgb(0, 0, 0)\"" << endl
|
||||
<< " stroke-width=\"" << width << "\"" << endl
|
||||
<< " stroke-linecap=\"butt\"" << endl
|
||||
<< " stroke-linejoin=\"miter\"" << endl
|
||||
<< " fill=\"none\"" << endl
|
||||
<< " >" << endl
|
||||
<< Edges2SVG(VO)
|
||||
<< "</g>" << endl;
|
||||
}
|
||||
if (!V.IsNull()) {
|
||||
float width = 0.35f/scale;
|
||||
BRepMesh::Mesh(V,0.1);
|
||||
result << "<g"
|
||||
//<< " id=\"" << ViewName << "\"" << endl
|
||||
<< " stroke=\"rgb(0, 0, 0)\"" << endl
|
||||
<< " stroke-width=\"" << width << "\"" << endl
|
||||
<< " stroke-linecap=\"butt\"" << endl
|
||||
<< " stroke-linejoin=\"miter\"" << endl
|
||||
<< " fill=\"none\"" << endl
|
||||
<< " >" << endl
|
||||
<< Edges2SVG(V)
|
||||
<< "</g>" << endl;
|
||||
}
|
||||
if (!V1.IsNull() && (type & WithSmooth)) {
|
||||
float width = 0.35f/scale;
|
||||
BRepMesh::Mesh(V1,0.1);
|
||||
result << "<g"
|
||||
//<< " id=\"" << ViewName << "\"" << endl
|
||||
<< " stroke=\"rgb(0, 0, 0)\"" << endl
|
||||
<< " stroke-width=\"" << width << "\"" << endl
|
||||
<< " stroke-linecap=\"butt\"" << endl
|
||||
<< " stroke-linejoin=\"miter\"" << endl
|
||||
<< " fill=\"none\"" << endl
|
||||
<< " >" << endl
|
||||
<< Edges2SVG(V1)
|
||||
<< "</g>" << endl;
|
||||
}
|
||||
if (!H1.IsNull() && (type & WithSmooth) && (type & WithHidden)) {
|
||||
float width = 0.15f/scale;
|
||||
BRepMesh::Mesh(H1,0.1);
|
||||
result << "<g"
|
||||
//<< " id=\"" << ViewName << "\"" << endl
|
||||
<< " stroke=\"rgb(0, 0, 0)\"" << endl
|
||||
<< " stroke-width=\"" << width << "\"" << endl
|
||||
<< " stroke-linecap=\"butt\"" << endl
|
||||
<< " stroke-linejoin=\"miter\"" << endl
|
||||
<< " stroke-dasharray=\"5 3\"" << endl
|
||||
<< " fill=\"none\"" << endl
|
||||
<< " >" << endl
|
||||
<< Edges2SVG(H1)
|
||||
<< "</g>" << endl;
|
||||
}
|
||||
|
||||
return result.str();
|
||||
}
|
||||
|
||||
std::string ProjectionAlgos::Edges2SVG(const TopoDS_Shape &Input)
|
||||
{
|
||||
std::stringstream result;
|
||||
|
||||
TopExp_Explorer edges( Input, TopAbs_EDGE );
|
||||
for (int i = 1 ; edges.More(); edges.Next(),i++ ) {
|
||||
const TopoDS_Edge& edge = TopoDS::Edge(edges.Current());
|
||||
BRepAdaptor_Curve adapt(edge);
|
||||
if (adapt.GetType() == GeomAbs_Circle) {
|
||||
printCircle(adapt, result);
|
||||
}
|
||||
else if (adapt.GetType() == GeomAbs_Ellipse) {
|
||||
printEllipse(adapt, i, result);
|
||||
}
|
||||
else if (adapt.GetType() == GeomAbs_BSplineCurve) {
|
||||
printBSpline(adapt, i, result);
|
||||
}
|
||||
// fallback
|
||||
else {
|
||||
printGeneric(adapt, i, result);
|
||||
}
|
||||
}
|
||||
|
||||
return result.str();
|
||||
}
|
||||
|
||||
void ProjectionAlgos::printGeneric(const BRepAdaptor_Curve& c, int id, std::ostream& out)
|
||||
{
|
||||
TopLoc_Location location;
|
||||
Handle(Poly_Polygon3D) polygon = BRep_Tool::Polygon3D(c.Edge(), location);
|
||||
if (!polygon.IsNull()) {
|
||||
const TColgp_Array1OfPnt& nodes = polygon->Nodes();
|
||||
char c = 'M';
|
||||
out << "<path id= \"" /*<< ViewName*/ << id << "\" d=\" ";
|
||||
for (int i = nodes.Lower(); i <= nodes.Upper(); i++){
|
||||
out << c << " " << nodes(i).X() << " " << nodes(i).Y()<< " " ;
|
||||
c = 'L';
|
||||
}
|
||||
out << "\" />" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectionAlgos::printCircle(const BRepAdaptor_Curve& c, std::ostream& out)
|
||||
{
|
||||
gp_Circ circ = c.Circle();
|
||||
const gp_Pnt& p= circ.Location();
|
||||
double r = circ.Radius();
|
||||
double f = c.FirstParameter();
|
||||
double l = c.LastParameter();
|
||||
gp_Pnt s = c.Value(f);
|
||||
gp_Pnt m = c.Value((l+f)/2.0);
|
||||
gp_Pnt e = c.Value(l);
|
||||
|
||||
gp_Vec v1(m,s);
|
||||
gp_Vec v2(m,e);
|
||||
gp_Vec v3(0,0,1);
|
||||
double a = v3.DotCross(v1,v2);
|
||||
|
||||
// a full circle
|
||||
if (s.SquareDistance(e) < 0.001) {
|
||||
out << "<circle cx =\"" << p.X() << "\" cy =\""
|
||||
<< p.Y() << "\" r =\"" << r << "\" />";
|
||||
}
|
||||
// arc of circle
|
||||
else {
|
||||
// See also https://developer.mozilla.org/en/SVG/Tutorial/Paths
|
||||
char xar = '0'; // x-axis-rotation
|
||||
char las = (l-f > D_PI) ? '1' : '0'; // large-arc-flag
|
||||
char swp = (a < 0) ? '1' : '0'; // sweep-flag, i.e. clockwise (0) or counter-clockwise (1)
|
||||
out << "<path d=\"M" << s.X() << " " << s.Y()
|
||||
<< " A" << r << " " << r << " "
|
||||
<< xar << " " << las << " " << swp << " "
|
||||
<< e.X() << " " << e.Y() << "\" />";
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectionAlgos::printEllipse(const BRepAdaptor_Curve& c, int id, std::ostream& out)
|
||||
{
|
||||
gp_Elips ellp = c.Ellipse();
|
||||
const gp_Pnt& p= ellp.Location();
|
||||
double r1 = ellp.MajorRadius();
|
||||
double r2 = ellp.MinorRadius();
|
||||
double f = c.FirstParameter();
|
||||
double l = c.LastParameter();
|
||||
gp_Pnt s = c.Value(f);
|
||||
gp_Pnt m = c.Value((l+f)/2.0);
|
||||
gp_Pnt e = c.Value(l);
|
||||
|
||||
gp_Vec v1(m,s);
|
||||
gp_Vec v2(m,e);
|
||||
gp_Vec v3(0,0,1);
|
||||
double a = v3.DotCross(v1,v2);
|
||||
|
||||
// a full ellipse
|
||||
if (s.SquareDistance(e) < 0.001) {
|
||||
out << "<ellipse cx =\"" << p.X() << "\" cy =\""
|
||||
<< p.Y() << "\" rx =\"" << r1 << "\" ry =\"" << r2 << "\"/>";
|
||||
}
|
||||
// arc of ellipse
|
||||
else {
|
||||
// See also https://developer.mozilla.org/en/SVG/Tutorial/Paths
|
||||
gp_Dir xaxis = ellp.XAxis().Direction();
|
||||
Standard_Real angle = xaxis.Angle(gp_Dir(1,0,0));
|
||||
angle = Base::toDegrees<double>(angle);
|
||||
char las = (l-f > D_PI) ? '1' : '0'; // large-arc-flag
|
||||
char swp = (a < 0) ? '1' : '0'; // sweep-flag, i.e. clockwise (0) or counter-clockwise (1)
|
||||
out << "<path d=\"M" << s.X() << " " << s.Y()
|
||||
<< " A" << r1 << " " << r2 << " "
|
||||
<< angle << " " << las << " " << swp << " "
|
||||
<< e.X() << " " << e.Y() << "\" />";
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectionAlgos::printBSpline(const BRepAdaptor_Curve& c, int id, std::ostream& out)
|
||||
{
|
||||
try {
|
||||
std::stringstream str;
|
||||
Handle_Geom_BSplineCurve spline = c.BSpline();
|
||||
if (spline->Degree() > 3) {
|
||||
Standard_Real tol3D = 0.001;
|
||||
Standard_Integer maxDegree = 3, maxSegment = 10;
|
||||
Handle_BRepAdaptor_HCurve hCurve = new BRepAdaptor_HCurve(c);
|
||||
// approximate the curve using a tolerance
|
||||
Approx_Curve3d approx(hCurve,tol3D,GeomAbs_C2,maxSegment,maxDegree);
|
||||
if (approx.IsDone() && approx.HasResult()) {
|
||||
// have the result
|
||||
spline = approx.Curve();
|
||||
}
|
||||
}
|
||||
|
||||
GeomConvert_BSplineCurveToBezierCurve crt(spline);
|
||||
Standard_Integer arcs = crt.NbArcs();
|
||||
str << "<path d=\"M";
|
||||
for (Standard_Integer i=1; i<=arcs; i++) {
|
||||
Handle_Geom_BezierCurve bezier = crt.Arc(i);
|
||||
Standard_Integer poles = bezier->NbPoles();
|
||||
if (bezier->Degree() == 3) {
|
||||
if (poles != 4)
|
||||
Standard_Failure::Raise("do it the generic way");
|
||||
gp_Pnt p1 = bezier->Pole(1);
|
||||
gp_Pnt p2 = bezier->Pole(2);
|
||||
gp_Pnt p3 = bezier->Pole(3);
|
||||
gp_Pnt p4 = bezier->Pole(4);
|
||||
if (i == 1) {
|
||||
str << p1.X() << "," << p1.Y() << " C"
|
||||
<< p2.X() << "," << p2.Y() << " "
|
||||
<< p3.X() << "," << p3.Y() << " "
|
||||
<< p4.X() << "," << p4.Y() << " ";
|
||||
}
|
||||
else {
|
||||
str << "S"
|
||||
<< p3.X() << "," << p3.Y() << " "
|
||||
<< p4.X() << "," << p4.Y() << " ";
|
||||
}
|
||||
}
|
||||
else if (bezier->Degree() == 2) {
|
||||
if (poles != 3)
|
||||
Standard_Failure::Raise("do it the generic way");
|
||||
gp_Pnt p1 = bezier->Pole(1);
|
||||
gp_Pnt p2 = bezier->Pole(2);
|
||||
gp_Pnt p3 = bezier->Pole(3);
|
||||
if (i == 1) {
|
||||
str << p1.X() << "," << p1.Y() << " Q"
|
||||
<< p2.X() << "," << p2.Y() << " "
|
||||
<< p3.X() << "," << p3.Y() << " ";
|
||||
}
|
||||
else {
|
||||
str << "T"
|
||||
<< p3.X() << "," << p3.Y() << " ";
|
||||
}
|
||||
}
|
||||
else {
|
||||
Standard_Failure::Raise("do it the generic way");
|
||||
}
|
||||
}
|
||||
|
||||
str << "\" />";
|
||||
out << str.str();
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
printGeneric(c, id, out);
|
||||
}
|
||||
}
|
||||
82
src/Mod/Drawing/App/ProjectionAlgos.h
Normal file
82
src/Mod/Drawing/App/ProjectionAlgos.h
Normal file
@@ -0,0 +1,82 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) Jürgen Riegel (juergen.riegel@web.de) 2009 *
|
||||
* *
|
||||
* 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 _ProjectionAlgos_h_
|
||||
#define _ProjectionAlgos_h_
|
||||
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <Base/Vector3D.h>
|
||||
#include <string>
|
||||
|
||||
class BRepAdaptor_Curve;
|
||||
|
||||
namespace Drawing
|
||||
{
|
||||
|
||||
/** Algo class for projecting shapes and creating SVG output of it
|
||||
*/
|
||||
class DrawingExport ProjectionAlgos
|
||||
{
|
||||
public:
|
||||
/// Constructor
|
||||
ProjectionAlgos(const TopoDS_Shape &Input,const Base::Vector3f &Dir);
|
||||
virtual ~ProjectionAlgos();
|
||||
|
||||
void execute(void);
|
||||
static TopoDS_Shape invertY(const TopoDS_Shape&);
|
||||
|
||||
std::string Edges2SVG(const TopoDS_Shape &);
|
||||
|
||||
enum SvgExtractionType {
|
||||
Plain = 0,
|
||||
WithHidden = 1,
|
||||
WithSmooth = 2
|
||||
};
|
||||
|
||||
std::string getSVG(SvgExtractionType type, float scale);
|
||||
|
||||
const TopoDS_Shape &Input;
|
||||
const Base::Vector3f &Direction;
|
||||
|
||||
TopoDS_Shape V ;// hard edge visibly
|
||||
TopoDS_Shape V1;// Smoth edges visibly
|
||||
TopoDS_Shape VN;// contour edges visibly
|
||||
TopoDS_Shape VO;// contours apparents visibly
|
||||
TopoDS_Shape VI;// isoparamtriques visibly
|
||||
TopoDS_Shape H ;// hard edge invisibly
|
||||
TopoDS_Shape H1;// Smoth edges invisibly
|
||||
TopoDS_Shape HN;// contour edges invisibly
|
||||
TopoDS_Shape HO;// contours apparents invisibly
|
||||
TopoDS_Shape HI;// isoparamtriques invisibly
|
||||
|
||||
private:
|
||||
void printCircle(const BRepAdaptor_Curve&, std::ostream&);
|
||||
void printEllipse(const BRepAdaptor_Curve&, int id, std::ostream&);
|
||||
void printBSpline(const BRepAdaptor_Curve&, int id, std::ostream&);
|
||||
void printGeneric(const BRepAdaptor_Curve&, int id, std::ostream&);
|
||||
};
|
||||
|
||||
} //namespace Drawing
|
||||
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user