Merge branch 'master' of ssh://free-cad.git.sourceforge.net/gitroot/free-cad/free-cad
This commit is contained in:
commit
ff8d712a4b
|
@ -587,6 +587,16 @@ void Matrix_invert (Matrix a, Matrix inva)
|
||||||
Matrix_gauss(temp,inva);
|
Matrix_gauss(temp,inva);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Matrix4D::inverseOrthogonal(void)
|
||||||
|
{
|
||||||
|
Base::Vector3d c(dMtrx4D[0][3],dMtrx4D[1][3],dMtrx4D[2][3]);
|
||||||
|
transpose();
|
||||||
|
c = this->operator * (c);
|
||||||
|
dMtrx4D[0][3] = -c.x; dMtrx4D[3][0] = 0;
|
||||||
|
dMtrx4D[1][3] = -c.y; dMtrx4D[3][1] = 0;
|
||||||
|
dMtrx4D[2][3] = -c.z; dMtrx4D[3][2] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void Matrix4D::inverseGauss (void)
|
void Matrix4D::inverseGauss (void)
|
||||||
{
|
{
|
||||||
double matrix [16];
|
double matrix [16];
|
||||||
|
|
|
@ -135,6 +135,8 @@ public:
|
||||||
void transform (const Vector3f& rclVct, const Matrix4D& rclMtrx);
|
void transform (const Vector3f& rclVct, const Matrix4D& rclMtrx);
|
||||||
void transform (const Vector3d& rclVct, const Matrix4D& rclMtrx);
|
void transform (const Vector3d& rclVct, const Matrix4D& rclMtrx);
|
||||||
void inverse (void);
|
void inverse (void);
|
||||||
|
/// if matrix is orthogonal a special way of getting the inverse is used
|
||||||
|
void inverseOrthogonal(void);
|
||||||
void inverseGauss (void);
|
void inverseGauss (void);
|
||||||
void transpose (void);
|
void transpose (void);
|
||||||
//@}
|
//@}
|
||||||
|
|
|
@ -576,7 +576,7 @@ void CreateStdCommands(void)
|
||||||
rcCmdMgr.addCommand(new StdCmdOnlineHelpWebsite());
|
rcCmdMgr.addCommand(new StdCmdOnlineHelpWebsite());
|
||||||
rcCmdMgr.addCommand(new StdCmdFreeCADWebsite());
|
rcCmdMgr.addCommand(new StdCmdFreeCADWebsite());
|
||||||
rcCmdMgr.addCommand(new StdCmdPythonWebsite());
|
rcCmdMgr.addCommand(new StdCmdPythonWebsite());
|
||||||
rcCmdMgr.addCommand(new StdCmdMeasurementSimple());
|
//rcCmdMgr.addCommand(new StdCmdMeasurementSimple());
|
||||||
//rcCmdMgr.addCommand(new StdCmdDownloadOnlineHelp());
|
//rcCmdMgr.addCommand(new StdCmdDownloadOnlineHelp());
|
||||||
//rcCmdMgr.addCommand(new StdCmdDescription());
|
//rcCmdMgr.addCommand(new StdCmdDescription());
|
||||||
}
|
}
|
||||||
|
|
|
@ -345,11 +345,24 @@ int PolyPickerSelection::mouseButtonEvent( const SoMouseButtonEvent * const e, c
|
||||||
m_iXnew = pos.x(); m_iYnew = pos.y();
|
m_iXnew = pos.x(); m_iYnew = pos.y();
|
||||||
m_iXold = pos.x(); m_iYold = pos.y();
|
m_iXold = pos.x(); m_iYold = pos.y();
|
||||||
}
|
}
|
||||||
|
} break;
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
} break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// release
|
||||||
|
else {
|
||||||
|
switch (button)
|
||||||
|
{
|
||||||
|
case SoMouseButtonEvent::BUTTON2:
|
||||||
|
{
|
||||||
QCursor cur = _pcView3D->getWidget()->cursor();
|
QCursor cur = _pcView3D->getWidget()->cursor();
|
||||||
_pcView3D->getWidget()->setCursor(m_cPrevCursor);
|
_pcView3D->getWidget()->setCursor(m_cPrevCursor);
|
||||||
// _pcView3D->getGLWidget()->releaseMouse();
|
|
||||||
|
|
||||||
|
// The pop-up menu should be shown when releasing mouse button because
|
||||||
|
// otherwise the navigation style doesn't get the UP event and gets into
|
||||||
|
// an inconsistent state.
|
||||||
int id = popupMenu();
|
int id = popupMenu();
|
||||||
if (id == Finish || id == Cancel) {
|
if (id == Finish || id == Cancel) {
|
||||||
releaseMouseModel();
|
releaseMouseModel();
|
||||||
|
|
|
@ -452,7 +452,7 @@ Gui::ToolBarItem* Workbench::setupToolBars() const
|
||||||
view->setCommand("View");
|
view->setCommand("View");
|
||||||
*view << "Std_ViewFitAll" << "Separator" << "Std_ViewAxo" << "Separator" << "Std_ViewFront"
|
*view << "Std_ViewFitAll" << "Separator" << "Std_ViewAxo" << "Separator" << "Std_ViewFront"
|
||||||
<< "Std_ViewRight" << "Std_ViewTop" << "Separator" << "Std_ViewRear" << "Std_ViewLeft"
|
<< "Std_ViewRight" << "Std_ViewTop" << "Separator" << "Std_ViewRear" << "Std_ViewLeft"
|
||||||
<< "Std_ViewBottom";
|
<< "Std_ViewBottom" << "Separator" << "Std_MeasureDistance";
|
||||||
|
|
||||||
// Part Design
|
// Part Design
|
||||||
Gui::ToolBarItem* part_design = new Gui::ToolBarItem( root );
|
Gui::ToolBarItem* part_design = new Gui::ToolBarItem( root );
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#include <Base/Reader.h>
|
#include <Base/Reader.h>
|
||||||
#include <Base/Interpreter.h>
|
#include <Base/Interpreter.h>
|
||||||
#include <Base/Sequencer.h>
|
#include <Base/Sequencer.h>
|
||||||
|
#include <Base/ViewProj.h>
|
||||||
|
|
||||||
#include "Core/Builder.h"
|
#include "Core/Builder.h"
|
||||||
#include "Core/MeshKernel.h"
|
#include "Core/MeshKernel.h"
|
||||||
|
@ -46,6 +47,8 @@
|
||||||
#include "Core/Degeneration.h"
|
#include "Core/Degeneration.h"
|
||||||
#include "Core/Segmentation.h"
|
#include "Core/Segmentation.h"
|
||||||
#include "Core/SetOperations.h"
|
#include "Core/SetOperations.h"
|
||||||
|
#include "Core/Triangulation.h"
|
||||||
|
#include "Core/Trim.h"
|
||||||
#include "Core/Visitor.h"
|
#include "Core/Visitor.h"
|
||||||
|
|
||||||
#include "Mesh.h"
|
#include "Mesh.h"
|
||||||
|
@ -812,6 +815,80 @@ void MeshObject::crossSections(const std::vector<MeshObject::TPlane>& planes, st
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MeshObject::cut(const std::vector<Base::Vector3f>& polygon, MeshObject::CutType type)
|
||||||
|
{
|
||||||
|
MeshCore::FlatTriangulator tria;
|
||||||
|
tria.SetPolygon(polygon);
|
||||||
|
// this gives us the inverse matrix
|
||||||
|
Base::Matrix4D inv = tria.GetTransformToFitPlane();
|
||||||
|
// compute the matrix for the coordinate transformation
|
||||||
|
Base::Matrix4D mat = inv;
|
||||||
|
mat.inverseOrthogonal();
|
||||||
|
|
||||||
|
std::vector<Base::Vector3f> poly = tria.ProjectToFitPlane();
|
||||||
|
|
||||||
|
Base::ViewProjMatrix proj(mat);
|
||||||
|
Base::Polygon2D polygon2d;
|
||||||
|
for (std::vector<Base::Vector3f>::const_iterator it = poly.begin(); it != poly.end(); ++it)
|
||||||
|
polygon2d.Add(Base::Vector2D(it->x, it->y));
|
||||||
|
|
||||||
|
MeshCore::MeshAlgorithm meshAlg(this->_kernel);
|
||||||
|
std::vector<unsigned long> check;
|
||||||
|
|
||||||
|
bool inner;
|
||||||
|
switch (type) {
|
||||||
|
case INNER:
|
||||||
|
inner = true;
|
||||||
|
break;
|
||||||
|
case OUTER:
|
||||||
|
inner = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
MeshCore::MeshFacetGrid meshGrid(this->_kernel);
|
||||||
|
meshAlg.CheckFacets(meshGrid, &proj, polygon2d, inner, check);
|
||||||
|
if (!check.empty())
|
||||||
|
this->deleteFacets(check);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MeshObject::trim(const std::vector<Base::Vector3f>& polygon, MeshObject::CutType type)
|
||||||
|
{
|
||||||
|
MeshCore::FlatTriangulator tria;
|
||||||
|
tria.SetPolygon(polygon);
|
||||||
|
// this gives us the inverse matrix
|
||||||
|
Base::Matrix4D inv = tria.GetTransformToFitPlane();
|
||||||
|
// compute the matrix for the coordinate transformation
|
||||||
|
Base::Matrix4D mat = inv;
|
||||||
|
mat.inverseOrthogonal();
|
||||||
|
|
||||||
|
std::vector<Base::Vector3f> poly = tria.ProjectToFitPlane();
|
||||||
|
|
||||||
|
Base::ViewProjMatrix proj(mat);
|
||||||
|
Base::Polygon2D polygon2d;
|
||||||
|
for (std::vector<Base::Vector3f>::const_iterator it = poly.begin(); it != poly.end(); ++it)
|
||||||
|
polygon2d.Add(Base::Vector2D(it->x, it->y));
|
||||||
|
MeshCore::MeshTrimming trim(this->_kernel, &proj, polygon2d);
|
||||||
|
std::vector<unsigned long> check;
|
||||||
|
std::vector<MeshCore::MeshGeomFacet> triangle;
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case INNER:
|
||||||
|
trim.SetInnerOrOuter(MeshCore::MeshTrimming::INNER);
|
||||||
|
break;
|
||||||
|
case OUTER:
|
||||||
|
trim.SetInnerOrOuter(MeshCore::MeshTrimming::OUTER);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
MeshCore::MeshFacetGrid meshGrid(this->_kernel);
|
||||||
|
trim.CheckFacets(meshGrid, check);
|
||||||
|
trim.TrimFacets(check, triangle);
|
||||||
|
if (!check.empty())
|
||||||
|
this->deleteFacets(check);
|
||||||
|
if (!triangle.empty())
|
||||||
|
this->_kernel.AddFacets(triangle);
|
||||||
|
}
|
||||||
|
|
||||||
MeshObject* MeshObject::unite(const MeshObject& mesh) const
|
MeshObject* MeshObject::unite(const MeshObject& mesh) const
|
||||||
{
|
{
|
||||||
MeshCore::MeshKernel result;
|
MeshCore::MeshKernel result;
|
||||||
|
@ -1423,7 +1500,7 @@ MeshObject* MeshObject::meshFromSegment(const std::vector<unsigned long>& indice
|
||||||
return new MeshObject(kernel, _Mtrx);
|
return new MeshObject(kernel, _Mtrx);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Segment> MeshObject::getSegmentsFromType(MeshObject::Type type, const Segment& aSegment,
|
std::vector<Segment> MeshObject::getSegmentsFromType(MeshObject::GeometryType type, const Segment& aSegment,
|
||||||
float dev, unsigned long minFacets) const
|
float dev, unsigned long minFacets) const
|
||||||
{
|
{
|
||||||
std::vector<Segment> segm;
|
std::vector<Segment> segm;
|
||||||
|
|
|
@ -66,7 +66,8 @@ class MeshExport MeshObject : public Data::ComplexGeoData
|
||||||
TYPESYSTEM_HEADER();
|
TYPESYSTEM_HEADER();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum Type {PLANE, CYLINDER, SPHERE};
|
enum GeometryType {PLANE, CYLINDER, SPHERE};
|
||||||
|
enum CutType {INNER, OUTER};
|
||||||
|
|
||||||
// typedef needed for cross-section
|
// typedef needed for cross-section
|
||||||
typedef std::pair<Base::Vector3f, Base::Vector3f> TPlane;
|
typedef std::pair<Base::Vector3f, Base::Vector3f> TPlane;
|
||||||
|
@ -198,6 +199,8 @@ public:
|
||||||
Base::Vector3d getPointNormal(unsigned long) const;
|
Base::Vector3d getPointNormal(unsigned long) const;
|
||||||
void crossSections(const std::vector<TPlane>&, std::vector<TPolylines> §ions,
|
void crossSections(const std::vector<TPlane>&, std::vector<TPolylines> §ions,
|
||||||
float fMinEps = 1.0e-2f, bool bConnectPolygons = false) const;
|
float fMinEps = 1.0e-2f, bool bConnectPolygons = false) const;
|
||||||
|
void cut(const std::vector<Base::Vector3f>& polygon, CutType);
|
||||||
|
void trim(const std::vector<Base::Vector3f>& polygon, CutType);
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
/** @name Selection */
|
/** @name Selection */
|
||||||
|
@ -266,7 +269,7 @@ public:
|
||||||
const Segment& getSegment(unsigned long) const;
|
const Segment& getSegment(unsigned long) const;
|
||||||
Segment& getSegment(unsigned long);
|
Segment& getSegment(unsigned long);
|
||||||
MeshObject* meshFromSegment(const std::vector<unsigned long>&) const;
|
MeshObject* meshFromSegment(const std::vector<unsigned long>&) const;
|
||||||
std::vector<Segment> getSegmentsFromType(Type, const Segment& aSegment, float dev, unsigned long minFacets) const;
|
std::vector<Segment> getSegmentsFromType(GeometryType, const Segment& aSegment, float dev, unsigned long minFacets) const;
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
/** @name Primitives */
|
/** @name Primitives */
|
||||||
|
|
|
@ -327,6 +327,24 @@ for c in mesh.getSeparatecomponents():
|
||||||
<UserDocu>Get a list of facet indices and intersection points</UserDocu>
|
<UserDocu>Get a list of facet indices and intersection points</UserDocu>
|
||||||
</Documentation>
|
</Documentation>
|
||||||
</Methode>
|
</Methode>
|
||||||
|
<Methode Name="cut">
|
||||||
|
<Documentation>
|
||||||
|
<UserDocu>Cuts the mesh with a given closed polygon
|
||||||
|
cut(list, int) -> None
|
||||||
|
The argument list is an array of points, a polygon
|
||||||
|
The argument int is the mode: 0=inner, 1=outer
|
||||||
|
</UserDocu>
|
||||||
|
</Documentation>
|
||||||
|
</Methode>
|
||||||
|
<Methode Name="trim">
|
||||||
|
<Documentation>
|
||||||
|
<UserDocu>Trims the mesh with a given closed polygon
|
||||||
|
trim(list, int) -> None
|
||||||
|
The argument list is an array of points, a polygon
|
||||||
|
The argument int is the mode: 0=inner, 1=outer
|
||||||
|
</UserDocu>
|
||||||
|
</Documentation>
|
||||||
|
</Methode>
|
||||||
<!-- The Const here is just a hack -->
|
<!-- The Const here is just a hack -->
|
||||||
<Methode Name="harmonizeNormals" Const="true">
|
<Methode Name="harmonizeNormals" Const="true">
|
||||||
<Documentation>
|
<Documentation>
|
||||||
|
|
|
@ -35,12 +35,12 @@
|
||||||
#include "MeshPy.cpp"
|
#include "MeshPy.cpp"
|
||||||
#include "MeshProperties.h"
|
#include "MeshProperties.h"
|
||||||
#include "Core/Algorithm.h"
|
#include "Core/Algorithm.h"
|
||||||
|
#include "Core/Triangulation.h"
|
||||||
#include "Core/Iterator.h"
|
#include "Core/Iterator.h"
|
||||||
#include "Core/Degeneration.h"
|
#include "Core/Degeneration.h"
|
||||||
#include "Core/Elements.h"
|
#include "Core/Elements.h"
|
||||||
#include "Core/Grid.h"
|
#include "Core/Grid.h"
|
||||||
#include "Core/MeshKernel.h"
|
#include "Core/MeshKernel.h"
|
||||||
#include "Core/Triangulation.h"
|
|
||||||
#include "Core/Segmentation.h"
|
#include "Core/Segmentation.h"
|
||||||
#include "Core/Curvature.h"
|
#include "Core/Curvature.h"
|
||||||
|
|
||||||
|
@ -1280,6 +1280,46 @@ PyObject* MeshPy::foraminate(PyObject *args)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PyObject* MeshPy::cut(PyObject *args)
|
||||||
|
{
|
||||||
|
PyObject* poly;
|
||||||
|
int mode;
|
||||||
|
if (!PyArg_ParseTuple(args, "O!i", &PyList_Type, &poly, &mode))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
Py::List list(poly);
|
||||||
|
std::vector<Base::Vector3f> polygon;
|
||||||
|
polygon.reserve(list.size());
|
||||||
|
for (Py::List::iterator it = list.begin(); it != list.end(); ++it) {
|
||||||
|
Base::Vector3d pnt = Py::Vector(*it).toVector();
|
||||||
|
polygon.push_back(Base::convertTo<Base::Vector3f>(pnt));
|
||||||
|
}
|
||||||
|
|
||||||
|
getMeshObjectPtr()->cut(polygon, MeshObject::CutType(mode));
|
||||||
|
|
||||||
|
Py_Return;
|
||||||
|
}
|
||||||
|
|
||||||
|
PyObject* MeshPy::trim(PyObject *args)
|
||||||
|
{
|
||||||
|
PyObject* poly;
|
||||||
|
int mode;
|
||||||
|
if (!PyArg_ParseTuple(args, "O!i", &PyList_Type, &poly, &mode))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
Py::List list(poly);
|
||||||
|
std::vector<Base::Vector3f> polygon;
|
||||||
|
polygon.reserve(list.size());
|
||||||
|
for (Py::List::iterator it = list.begin(); it != list.end(); ++it) {
|
||||||
|
Base::Vector3d pnt = Py::Vector(*it).toVector();
|
||||||
|
polygon.push_back(Base::convertTo<Base::Vector3f>(pnt));
|
||||||
|
}
|
||||||
|
|
||||||
|
getMeshObjectPtr()->trim(polygon, MeshObject::CutType(mode));
|
||||||
|
|
||||||
|
Py_Return;
|
||||||
|
}
|
||||||
|
|
||||||
PyObject* MeshPy::smooth(PyObject *args)
|
PyObject* MeshPy::smooth(PyObject *args)
|
||||||
{
|
{
|
||||||
int iter=1;
|
int iter=1;
|
||||||
|
|
|
@ -145,6 +145,7 @@
|
||||||
# include <ShapeFix_Shape.hxx>
|
# include <ShapeFix_Shape.hxx>
|
||||||
# include <XSControl_WorkSession.hxx>
|
# include <XSControl_WorkSession.hxx>
|
||||||
# include <Transfer_TransientProcess.hxx>
|
# include <Transfer_TransientProcess.hxx>
|
||||||
|
# include <Transfer_FinderProcess.hxx>
|
||||||
# include <APIHeaderSection_MakeHeader.hxx>
|
# include <APIHeaderSection_MakeHeader.hxx>
|
||||||
|
|
||||||
#include <Base/Builder3D.h>
|
#include <Base/Builder3D.h>
|
||||||
|
@ -696,7 +697,7 @@ void TopoShape::exportStep(const char *filename) const
|
||||||
STEPControl_Writer aWriter;
|
STEPControl_Writer aWriter;
|
||||||
|
|
||||||
Handle_Message_ProgressIndicator pi = new ProgressIndicator(100);
|
Handle_Message_ProgressIndicator pi = new ProgressIndicator(100);
|
||||||
aWriter.WS()->MapReader()->SetProgress(pi);
|
aWriter.WS()->MapWriter()->SetProgress(pi);
|
||||||
pi->NewScope(100, "Writing STEP file...");
|
pi->NewScope(100, "Writing STEP file...");
|
||||||
pi->Show();
|
pi->Show();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user