Merge branch 'master' of ssh://free-cad.git.sourceforge.net/gitroot/free-cad/free-cad

This commit is contained in:
Joachim Zettler
2012-03-27 14:02:12 +02:00
60 changed files with 2274 additions and 232 deletions

View File

@@ -257,6 +257,25 @@ class _Wall(ArchComponent.Component):
if prop in ["Base","Height","Width","Align","Additions","Subtractions"]:
self.createGeometry(obj)
def getSubVolume(self,base,width,delta=None):
"returns a subvolume from a base object"
import Part
max_length = 0
for w in base.Shape.Wires:
if w.BoundBox.DiagonalLength > max_length:
max_length = w.BoundBox.DiagonalLength
f = w
f = Part.Face(f)
n = f.normalAt(0,0)
v1 = fcvec.scaleTo(n,width)
f.translate(v1)
v2 = fcvec.neg(v1)
v2 = fcvec.scale(v1,-2)
f = f.extrude(v2)
if delta:
f.translate(delta)
return f
def createGeometry(self,obj):
import Part
@@ -339,17 +358,18 @@ class _Wall(ArchComponent.Component):
base = base.oldFuse(app.Shape)
app.ViewObject.hide() #to be removed
for hole in obj.Subtractions:
cut = False
if hasattr(hole,"Proxy"):
if hasattr(hole.Proxy,"Subvolume"):
if hole.Proxy.Subvolume:
print "cutting subvolume",hole.Proxy.Subvolume
base = base.cut(hole.Proxy.Subvolume)
cut = True
if not cut:
if hasattr(obj,"Shape"):
base = base.cut(hole.Shape)
hole.ViewObject.hide() # to be removed
if Draft.getType(hole) == "Window":
# window
if hole.Base and obj.Width:
f = self.getSubVolume(hole.Base,obj.Width)
base = base.cut(f)
elif Draft.isClone(hole,"Window"):
if hole.Objects[0].Base and obj.Width:
f = self.getSubVolume(hole.Objects[0].Base,obj.Width,hole.Placement.Base)
base = base.cut(f)
elif hasattr(obj,"Shape"):
base = base.cut(hole.Shape)
hole.ViewObject.hide() # to be removed
obj.Shape = base
if not fcgeo.isNull(pl):
obj.Placement = pl

View File

@@ -33,6 +33,10 @@ __url__ = "http://free-cad.sourceforge.net"
def makeWindow(baseobj=None,name="Window"):
'''makeWindow(obj,[name]): creates a window based on the
given object'''
if baseobj:
if Draft.getType(baseobj) == "Window":
obj = Draft.clone(baseobj)
return obj
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
_Window(obj)
_ViewProviderWindow(obj.ViewObject)
@@ -121,15 +125,16 @@ class _Window(ArchComponent.Component):
max_length = w.BoundBox.DiagonalLength
ext = w
wires.remove(ext)
for w in wires:
w.reverse()
wires.insert(0, ext)
shape = Part.Face(wires)
shape = Part.Face(ext)
norm = shape.normalAt(0,0)
thk = float(obj.WindowParts[(i*5)+3])
if thk:
exv = fcvec.scaleTo(norm,thk)
shape = shape.extrude(exv)
for w in wires:
f = Part.Face(w)
f = f.extrude(exv)
shape = shape.cut(f)
if obj.WindowParts[(i*5)+4]:
zof = float(obj.WindowParts[(i*5)+4])
if zof:

View File

@@ -36,6 +36,7 @@
<file>translations/Arch_ru.qm</file>
<file>translations/Arch_se.qm</file>
<file>translations/Arch_uk.qm</file>
<file>translations/Arch_pl.qm</file>
<file>translations/Arch_pt.qm</file>
<file>translations/Arch_hr.qm</file>
<file>translations/Arch_zh.qm</file>

View File

@@ -9,6 +9,7 @@
<file>translations/Complete_it.qm</file>
<file>translations/Complete_nl.qm</file>
<file>translations/Complete_no.qm</file>
<file>translations/Complete_pl.qm</file>
<file>translations/Complete_pt.qm</file>
<file>translations/Complete_ru.qm</file>
<file>translations/Complete_se.qm</file>

View File

@@ -16,6 +16,7 @@ EXTRA_DIST = \
translations/Complete_it.qm \
translations/Complete_nl.qm \
translations/Complete_no.qm \
translations/Complete_pl.qm \
translations/Complete_pt.qm \
translations/Complete_ru.qm \
translations/Complete_se.qm \
@@ -30,6 +31,7 @@ EXTRA_DIST = \
translations/Complete_it.ts \
translations/Complete_nl.ts \
translations/Complete_no.ts \
translations/Complete_pl.ts \
translations/Complete_pt.ts \
translations/Complete_ru.ts \
translations/Complete_se.ts \

View File

@@ -132,7 +132,8 @@ Gui::MenuItem* Workbench::setupMenuBar() const
edit->setCommand("&Edit");
*edit << "Std_Undo" << "Std_Redo" << "Separator" << "Std_Cut" << "Std_Copy"
<< "Std_Paste" << "Std_DuplicateSelection" << "Separator"
<< "Std_Refresh" << "Std_SelectAll" << "Std_Delete" << "Std_Placement"
<< "Std_Refresh" << "Std_SelectAll" << "Std_Delete"
<< "Std_Placement" << "Std_Alignment"
<< "Separator" << "Std_DlgPreferences";
// Standard views

View File

@@ -170,6 +170,15 @@ def getType(obj):
return "Group"
return "Unknown"
def isClone(obj,objtype):
"""isClone(obj,objtype): returns True if the given object is
a clone of an object of the given type"""
if getType(obj) == "Clone":
if len(obj.Objects) == 1:
if getType(obj.Objects[0]) == objtype:
return True
return False
def getGroupNames():
"returns a list of existing groups in the document"
glist = []
@@ -1581,8 +1590,11 @@ def clone(obj,delta=None):
if not isinstance(obj,list):
obj = [obj]
cl = FreeCAD.ActiveDocument.addObject("Part::FeaturePython","Clone")
cl.Label = "Clone of " + obj[0].Label
_Clone(cl)
_ViewProviderDraftPart(cl.ViewObject)
if gui:
_ViewProviderDraftPart(cl.ViewObject)
formatObject(cl,obj[0])
cl.Objects = obj
if delta:
cl.Placement.move(delta)
@@ -2813,3 +2825,6 @@ class _ViewProviderDraftPart(_ViewProviderDraft):
def getIcon(self):
return ":/icons/Tree_Part.svg"
def claimChildren(self):
return []

View File

@@ -57,6 +57,8 @@ EXTRA_DIST = \
Resources/translations/Draft_nl.qm \
Resources/translations/Draft_no.ts \
Resources/translations/Draft_no.qm \
Resources/translations/Draft_pl.ts \
Resources/translations/Draft_pl.qm \
Resources/translations/Draft_pt.ts \
Resources/translations/Draft_pt.qm \
Resources/translations/Draft_ru.ts \

View File

@@ -68,6 +68,7 @@
<file>translations/Draft_ru.qm</file>
<file>translations/Draft_se.qm</file>
<file>translations/Draft_uk.qm</file>
<file>translations/Draft_pl.qm</file>
<file>translations/Draft_pt.qm</file>
<file>translations/Draft_hr.qm</file>
<file>translations/Draft_zh.qm</file>

View File

@@ -25,6 +25,7 @@
<file>translations/Drawing_it.qm</file>
<file>translations/Drawing_nl.qm</file>
<file>translations/Drawing_no.qm</file>
<file>translations/Drawing_pl.qm</file>
<file>translations/Drawing_pt.qm</file>
<file>translations/Drawing_ru.qm</file>
<file>translations/Drawing_se.qm</file>

View File

@@ -32,6 +32,7 @@ EXTRA_DIST = \
translations/Drawing_it.qm \
translations/Drawing_nl.qm \
translations/Drawing_no.qm \
translations/Drawing_pl.qm \
translations/Drawing_pt.qm \
translations/Drawing_ru.qm \
translations/Drawing_se.qm \
@@ -46,6 +47,7 @@ EXTRA_DIST = \
translations/Drawing_it.ts \
translations/Drawing_nl.ts \
translations/Drawing_no.ts \
translations/Drawing_pl.ts \
translations/Drawing_pt.ts \
translations/Drawing_ru.ts \
translations/Drawing_se.ts \

View File

@@ -10,6 +10,7 @@
<file>translations/Fem_it.qm</file>
<file>translations/Fem_nl.qm</file>
<file>translations/Fem_no.qm</file>
<file>translations/Fem_pl.qm</file>
<file>translations/Fem_pt.qm</file>
<file>translations/Fem_ru.qm</file>
<file>translations/Fem_se.qm</file>

View File

@@ -26,6 +26,8 @@ EXTRA_DIST = \
translations/Fem_nl.ts \
translations/Fem_no.qm \
translations/Fem_no.ts \
translations/Fem_pl.qm \
translations/Fem_pl.ts \
translations/Fem_pt.qm \
translations/Fem_pt.ts \
translations/Fem_ru.qm \

View File

@@ -107,6 +107,8 @@ EXTRA_DIST = \
Resources/translations/Image_nl.ts \
Resources/translations/Image_no.qm \
Resources/translations/Image_no.ts \
Resources/translations/Image_pl.qm \
Resources/translations/Image_pl.ts \
Resources/translations/Image_pt.qm \
Resources/translations/Image_pt.ts \
Resources/translations/Image_ru.qm \

View File

@@ -10,6 +10,7 @@
<file>translations/Image_it.qm</file>
<file>translations/Image_nl.qm</file>
<file>translations/Image_no.qm</file>
<file>translations/Image_pl.qm</file>
<file>translations/Image_pt.qm</file>
<file>translations/Image_ru.qm</file>
<file>translations/Image_se.qm</file>

View File

@@ -661,7 +661,8 @@ bool MeshInput::LoadPLY (std::istream &inp)
return false; // wrong header
std::string line, element;
bool xyz_float=false,xyz_double=false,rgb_value=false;
bool xyz_float=false,xyz_double=false;
MeshIO::Binding rgb_value = MeshIO::OVERALL;
while (std::getline(inp, line)) {
std::istringstream str(line);
str.unsetf(std::ios_base::skipws);
@@ -738,7 +739,11 @@ bool MeshInput::LoadPLY (std::istream &inp)
xyz_double = true;
}
else if (name == "red") {
rgb_value = true;
rgb_value = MeshIO::PER_VERTEX;
if (_material) {
_material->binding = MeshIO::PER_VERTEX;
_material->diffuseColor.reserve(v_count);
}
}
}
else if (element == "face") {
@@ -753,9 +758,38 @@ bool MeshInput::LoadPLY (std::istream &inp)
boost::regex rx_p("^([-+]?[0-9]*)\\.?([0-9]+([eE][-+]?[0-9]+)?)"
"\\s+([-+]?[0-9]*)\\.?([0-9]+([eE][-+]?[0-9]+)?)"
"\\s+([-+]?[0-9]*)\\.?([0-9]+([eE][-+]?[0-9]+)?)\\s*$");
boost::regex rx_c("^([-+]?[0-9]*)\\.?([0-9]+([eE][-+]?[0-9]+)?)"
"\\s+([-+]?[0-9]*)\\.?([0-9]+([eE][-+]?[0-9]+)?)"
"\\s+([-+]?[0-9]*)\\.?([0-9]+([eE][-+]?[0-9]+)?)"
"\\s+([0-9]{1,3})\\s+([0-9]{1,3})\\s+([0-9]{1,3})\\s*$");
boost::regex rx_f("^\\s*3\\s+([0-9]+)\\s+([0-9]+)\\s+([0-9]+)\\s*$");
boost::cmatch what;
Base::Vector3f pt;
if (rgb_value == MeshIO::PER_VERTEX) {
int r,g,b;
for (std::size_t i = 0; i < v_count && std::getline(inp, line); i++) {
if (boost::regex_match(line.c_str(), what, rx_c)) {
pt.x = (float)std::atof(what[1].first);
pt.y = (float)std::atof(what[4].first);
pt.z = (float)std::atof(what[7].first);
meshPoints.push_back(pt);
if (_material) {
r = std::min<int>(std::atoi(what[10].first),255);
g = std::min<int>(std::atoi(what[11].first),255);
b = std::min<int>(std::atoi(what[12].first),255);
float fr = (float)r/255.0f;
float fg = (float)g/255.0f;
float fb = (float)b/255.0f;
_material->diffuseColor.push_back(App::Color(fr, fg, fb));
}
}
else {
return false;
}
}
}
else {
for (std::size_t i = 0; i < v_count && std::getline(inp, line); i++) {
if (boost::regex_match(line.c_str(), what, rx_p)) {
pt.x = (float)std::atof(what[1].first);
@@ -767,6 +801,7 @@ bool MeshInput::LoadPLY (std::istream &inp)
return false;
}
}
}
int f1, f2, f3;
for (std::size_t i = 0; i < f_count && std::getline(inp, line); i++) {
if (boost::regex_match(line.c_str(), what, rx_f)) {
@@ -777,6 +812,7 @@ bool MeshInput::LoadPLY (std::istream &inp)
}
}
}
// binary
else {
Base::InputStream is(inp);
if (format == binary_little_endian)
@@ -789,16 +825,31 @@ bool MeshInput::LoadPLY (std::istream &inp)
for (std::size_t i = 0; i < v_count; i++) {
is >> pt.x >> pt.y >> pt.z;
meshPoints.push_back(pt);
if (rgb_value)
if (rgb_value == MeshIO::PER_VERTEX) {
is >> r >> g >> b;
if (_material) {
float fr = (float)r/255.0f;
float fg = (float)g/255.0f;
float fb = (float)b/255.0f;
_material->diffuseColor.push_back(App::Color(fr, fg, fb));
}
}
}
}
else if (xyz_double) {
Base::Vector3d pt;
for (std::size_t i = 0; i < v_count; i++) {
is >> pt.x >> pt.y >> pt.z;
is >> r >> g >> b;
meshPoints.push_back(Base::Vector3f((float)pt.x,(float)pt.y,(float)pt.z));
if (rgb_value == MeshIO::PER_VERTEX) {
is >> r >> g >> b;
if (_material) {
float fr = (float)r/255.0f;
float fg = (float)g/255.0f;
float fb = (float)b/255.0f;
_material->diffuseColor.push_back(App::Color(fr, fg, fb));
}
}
}
}
unsigned char n;
@@ -1428,7 +1479,12 @@ bool MeshOutput::SaveAny(const char* FileName, MeshIO::Format format) const
}
else if (fileformat == MeshIO::PLY) {
// write file
if (!SavePLY(str))
if (!SaveBinaryPLY(str))
throw Base::FileException("Export of PLY mesh failed",FileName);
}
else if (fileformat == MeshIO::APLY) {
// write file
if (!SaveAsciiPLY(str))
throw Base::FileException("Export of PLY mesh failed",FileName);
}
else if (fileformat == MeshIO::IV) {
@@ -1646,7 +1702,7 @@ bool MeshOutput::SaveOFF (std::ostream &out) const
return true;
}
bool MeshOutput::SavePLY (std::ostream &out) const
bool MeshOutput::SaveBinaryPLY (std::ostream &out) const
{
const MeshPointArray& rPoints = _rclMesh.GetPoints();
const MeshFacetArray& rFacets = _rclMesh.GetFacets();
@@ -1706,6 +1762,81 @@ bool MeshOutput::SavePLY (std::ostream &out) const
return true;
}
bool MeshOutput::SaveAsciiPLY (std::ostream &out) const
{
const MeshPointArray& rPoints = _rclMesh.GetPoints();
const MeshFacetArray& rFacets = _rclMesh.GetFacets();
std::size_t v_count = rPoints.size();
std::size_t f_count = rFacets.size();
if (!out || out.bad() == true)
return false;
bool saveVertexColor = (_material && _material->binding == MeshIO::PER_VERTEX
&& _material->diffuseColor.size() == rPoints.size());
out << "ply" << std::endl
<< "format ascii 1.0" << std::endl
<< "comment Created by FreeCAD <http://free-cad.sourceforge.net>" << std::endl
<< "element vertex " << v_count << std::endl
<< "property float32 x" << std::endl
<< "property float32 y" << std::endl
<< "property float32 z" << std::endl;
if (saveVertexColor) {
out << "property uchar red" << std::endl
<< "property uchar green" << std::endl
<< "property uchar blue" << std::endl;
}
out << "element face " << f_count << std::endl
<< "property list uchar int vertex_index" << std::endl
<< "end_header" << std::endl;
Base::Vector3f pt;
out.precision(6);
out.setf(std::ios::fixed | std::ios::showpoint);
if (saveVertexColor) {
for (std::size_t i = 0; i < v_count; i++) {
const MeshPoint& p = rPoints[i];
if (this->apply_transform) {
Base::Vector3f pt = this->_transform * p;
out << pt.x << " " << pt.y << " " << pt.z;
}
else {
out << p.x << " " << p.y << " " << p.z;
}
const App::Color& c = _material->diffuseColor[i];
int r = (int)(255.0f * c.r);
int g = (int)(255.0f * c.g);
int b = (int)(255.0f * c.b);
out << " " << r << " " << g << " " << b << std::endl;
}
}
else {
for (std::size_t i = 0; i < v_count; i++) {
const MeshPoint& p = rPoints[i];
if (this->apply_transform) {
Base::Vector3f pt = this->_transform * p;
out << pt.x << " " << pt.y << " " << pt.z << std::endl;
}
else {
out << p.x << " " << p.y << " " << p.z << std::endl;
}
}
}
unsigned int n = 3;
int f1, f2, f3;
for (std::size_t i = 0; i < f_count; i++) {
const MeshFacet& f = rFacets[i];
f1 = (int)f._aulPoints[0];
f2 = (int)f._aulPoints[1];
f3 = (int)f._aulPoints[2];
out << n << " " << f1 << " " << f2 << " " << f3 << std::endl;
}
return true;
}
bool MeshOutput::SaveMeshNode (std::ostream &rstrOut)
{
const MeshPointArray& rPoints = _rclMesh.GetPoints();

View File

@@ -51,6 +51,7 @@ namespace MeshIO {
WRZ,
NAS,
PLY,
APLY,
PY
};
enum Binding {
@@ -74,7 +75,10 @@ struct MeshExport Material
class MeshExport MeshInput
{
public:
MeshInput (MeshKernel &rclM): _rclMesh(rclM){};
MeshInput (MeshKernel &rclM)
: _rclMesh(rclM), _material(0){}
MeshInput (MeshKernel &rclM, Material* m)
: _rclMesh(rclM), _material(m){}
virtual ~MeshInput (void) { }
/// Loads the file, decided by extension
@@ -106,6 +110,7 @@ public:
protected:
MeshKernel &_rclMesh; /**< reference to mesh data structure */
Material* _material;
};
/**
@@ -138,8 +143,10 @@ public:
bool SaveOBJ (std::ostream &rstrOut) const;
/** Saves the mesh object into an OFF file. */
bool SaveOFF (std::ostream &rstrOut) const;
/** Saves the mesh object into a PLY file. */
bool SavePLY (std::ostream &rstrOut) const;
/** Saves the mesh object into a binary PLY file. */
bool SaveBinaryPLY (std::ostream &rstrOut) const;
/** Saves the mesh object into an ASCII PLY file. */
bool SaveAsciiPLY (std::ostream &rstrOut) const;
/** Saves the mesh object into an XML file. */
void SaveXML (Base::Writer &writer) const;
/** Saves a node to an OpenInventor file. */

View File

@@ -311,10 +311,10 @@ void MeshObject::save(std::ostream& out) const
_kernel.Write(out);
}
bool MeshObject::load(const char* file)
bool MeshObject::load(const char* file, MeshCore::Material* mat)
{
MeshCore::MeshKernel kernel;
MeshCore::MeshInput aReader(kernel);
MeshCore::MeshInput aReader(kernel, mat);
if (!aReader.LoadAny(file))
return false;
@@ -631,6 +631,32 @@ void MeshObject::removeComponents(unsigned long count)
deletedFacets(removeIndices);
}
unsigned long MeshObject::getPointDegree(const std::vector<unsigned long>& indices,
std::vector<unsigned long>& point_degree) const
{
const MeshCore::MeshFacetArray& faces = _kernel.GetFacets();
std::vector<unsigned long> pointDeg(_kernel.CountPoints());
for (MeshCore::MeshFacetArray::_TConstIterator it = faces.begin(); it != faces.end(); ++it) {
pointDeg[it->_aulPoints[0]]++;
pointDeg[it->_aulPoints[1]]++;
pointDeg[it->_aulPoints[2]]++;
}
for (std::vector<unsigned long>::const_iterator it = indices.begin(); it != indices.end(); ++it) {
const MeshCore::MeshFacet& face = faces[*it];
pointDeg[face._aulPoints[0]]--;
pointDeg[face._aulPoints[1]]--;
pointDeg[face._aulPoints[2]]--;
}
unsigned long countInvalids = std::count_if(pointDeg.begin(), pointDeg.end(),
std::bind2nd(std::equal_to<unsigned long>(), 0));
point_degree = pointDeg;
return countInvalids;
}
void MeshObject::fillupHoles(unsigned long length, int level,
MeshCore::AbstractPolygonTriangulator& cTria)
{

View File

@@ -144,7 +144,7 @@ public:
void save(const char* file,MeshCore::MeshIO::Format f=MeshCore::MeshIO::Undefined,
const MeshCore::Material* mat = 0) const;
void save(std::ostream&) const;
bool load(const char* file);
bool load(const char* file, MeshCore::Material* mat = 0);
void load(std::istream&);
//@}
@@ -177,6 +177,14 @@ public:
std::vector<std::vector<unsigned long> > getComponents() const;
unsigned long countComponents() const;
void removeComponents(unsigned long);
/**
* Checks for the given facet indices what will be the degree for each point
* when these facets are removed from the mesh kernel.
* The point degree information is stored in \a point_degree. The return value
* gices the number of points which will have a degree of zero.
*/
unsigned long getPointDegree(const std::vector<unsigned long>& facets,
std::vector<unsigned long>& point_degree) const;
void fillupHoles(unsigned long, int, MeshCore::AbstractPolygonTriangulator&);
void offset(float fSize);
void offsetSpecial2(float fSize);

View File

@@ -77,7 +77,10 @@ PyObject* MeshFeaturePy::smooth(PyObject *args)
return NULL;
PY_TRY {
getFeaturePtr()->Mesh.smooth(iter, d_max);
Mesh::Feature* obj = getFeaturePtr();
MeshObject* kernel = obj->Mesh.startEditing();
kernel->smooth(iter, d_max);
obj->Mesh.finishEditing();
} PY_CATCH;
Py_Return;
@@ -87,7 +90,10 @@ PyObject* MeshFeaturePy::removeNonManifolds(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return NULL;
getFeaturePtr()->Mesh.removeNonManifolds();
Mesh::Feature* obj = getFeaturePtr();
MeshObject* kernel = obj->Mesh.startEditing();
kernel->removeNonManifolds();
obj->Mesh.finishEditing();
Py_Return
}
@@ -97,7 +103,10 @@ PyObject* MeshFeaturePy::fixIndices(PyObject *args)
return NULL;
PY_TRY {
getFeaturePtr()->Mesh.validateIndices();
Mesh::Feature* obj = getFeaturePtr();
MeshObject* kernel = obj->Mesh.startEditing();
kernel->validateIndices();
obj->Mesh.finishEditing();
} PY_CATCH;
Py_Return;
@@ -109,7 +118,10 @@ PyObject* MeshFeaturePy::fixDegenerations(PyObject *args)
return NULL;
PY_TRY {
getFeaturePtr()->Mesh.validateDegenerations();
Mesh::Feature* obj = getFeaturePtr();
MeshObject* kernel = obj->Mesh.startEditing();
kernel->validateDegenerations();
obj->Mesh.finishEditing();
} PY_CATCH;
Py_Return;
@@ -121,7 +133,10 @@ PyObject* MeshFeaturePy::removeDuplicatedFacets(PyObject *args)
return NULL;
PY_TRY {
getFeaturePtr()->Mesh.removeDuplicatedFacets();
Mesh::Feature* obj = getFeaturePtr();
MeshObject* kernel = obj->Mesh.startEditing();
kernel->removeDuplicatedFacets();
obj->Mesh.finishEditing();
} PY_CATCH;
Py_Return;
@@ -133,7 +148,10 @@ PyObject* MeshFeaturePy::removeDuplicatedPoints(PyObject *args)
return NULL;
PY_TRY {
getFeaturePtr()->Mesh.removeDuplicatedPoints();
Mesh::Feature* obj = getFeaturePtr();
MeshObject* kernel = obj->Mesh.startEditing();
kernel->removeDuplicatedPoints();
obj->Mesh.finishEditing();
} PY_CATCH;
Py_Return;
@@ -144,7 +162,10 @@ PyObject* MeshFeaturePy::fixSelfIntersections(PyObject *args)
if (!PyArg_ParseTuple(args, ""))
return NULL;
try {
getFeaturePtr()->Mesh.removeSelfIntersections();
Mesh::Feature* obj = getFeaturePtr();
MeshObject* kernel = obj->Mesh.startEditing();
kernel->removeSelfIntersections();
obj->Mesh.finishEditing();
}
catch (const Base::Exception& e) {
PyErr_SetString(PyExc_Exception, e.what());
@@ -158,7 +179,10 @@ PyObject* MeshFeaturePy::removeFoldsOnSurface(PyObject *args)
if (!PyArg_ParseTuple(args, ""))
return NULL;
try {
getFeaturePtr()->Mesh.removeFoldsOnSurface();
Mesh::Feature* obj = getFeaturePtr();
MeshObject* kernel = obj->Mesh.startEditing();
kernel->removeFoldsOnSurface();
obj->Mesh.finishEditing();
}
catch (const Base::Exception& e) {
PyErr_SetString(PyExc_Exception, e.what());

View File

@@ -390,20 +390,6 @@ void PropertyMeshKernel::transformGeometry(const Base::Matrix4D &rclMat)
hasSetValue();
}
void PropertyMeshKernel::deletePointIndices( const std::vector<unsigned long>& inds )
{
aboutToSetValue();
_meshObject->deletePoints(inds);
hasSetValue();
}
void PropertyMeshKernel::deleteFacetIndices( const std::vector<unsigned long>& inds )
{
aboutToSetValue();
_meshObject->deleteFacets(inds);
hasSetValue();
}
void PropertyMeshKernel::setPointIndices(const std::vector<std::pair<unsigned long, Base::Vector3f> >& inds)
{
aboutToSetValue();
@@ -413,99 +399,6 @@ void PropertyMeshKernel::setPointIndices(const std::vector<std::pair<unsigned lo
hasSetValue();
}
void PropertyMeshKernel::append(const std::vector<MeshCore::MeshFacet>& rFaces,
const std::vector<Base::Vector3f>& rPoints)
{
aboutToSetValue();
_meshObject->addFacets(rFaces, rPoints);
hasSetValue();
}
void PropertyMeshKernel::createSegment(const std::vector<unsigned long>& segm)
{
aboutToSetValue();
_meshObject->addSegment(segm);
hasSetValue();
}
void PropertyMeshKernel::smooth(int iter, float d_max)
{
aboutToSetValue();
_meshObject->smooth(iter, d_max);
hasSetValue();
}
void PropertyMeshKernel::clear()
{
// clear the underlying mesh kernel and free any allocated memory
aboutToSetValue();
_meshObject->clear();
hasSetValue();
}
void PropertyMeshKernel::harmonizeNormals()
{
aboutToSetValue();
_meshObject->harmonizeNormals();
hasSetValue();
}
void PropertyMeshKernel::removeNonManifolds()
{
aboutToSetValue();
_meshObject->removeNonManifolds();
hasSetValue();
}
void PropertyMeshKernel::validateIndices()
{
aboutToSetValue();
_meshObject->validateIndices();
hasSetValue();
}
void PropertyMeshKernel::validateDegenerations()
{
aboutToSetValue();
_meshObject->validateDegenerations();
hasSetValue();
}
void PropertyMeshKernel::validateDeformations(float fMaxAngle)
{
aboutToSetValue();
_meshObject->validateDeformations(fMaxAngle);
hasSetValue();
}
void PropertyMeshKernel::removeDuplicatedFacets()
{
aboutToSetValue();
_meshObject->removeDuplicatedFacets();
hasSetValue();
}
void PropertyMeshKernel::removeDuplicatedPoints()
{
aboutToSetValue();
_meshObject->removeDuplicatedPoints();
hasSetValue();
}
void PropertyMeshKernel::removeSelfIntersections()
{
aboutToSetValue();
_meshObject->removeSelfIntersections();
hasSetValue();
}
void PropertyMeshKernel::removeFoldsOnSurface()
{
aboutToSetValue();
_meshObject->removeFoldsOnSurface();
hasSetValue();
}
PyObject *PropertyMeshKernel::getPyObject(void)
{
if (!meshPyObject) {

View File

@@ -179,27 +179,7 @@ public:
void finishEditing();
/// Transform the real mesh data
void transformGeometry(const Base::Matrix4D &rclMat);
void deletePointIndices ( const std::vector<unsigned long>& );
void deleteFacetIndices ( const std::vector<unsigned long>& );
void setPointIndices( const std::vector<std::pair<unsigned long, Base::Vector3f> >& );
void append(const std::vector<MeshCore::MeshFacet>& rFaces,
const std::vector<Base::Vector3f>& rPoints);
void createSegment(const std::vector<unsigned long>& segm);
void smooth(int iter, float d_max);
void clear();
//@}
/** @name Mesh validation */
//@{
void harmonizeNormals();
void validateIndices();
void validateDeformations(float fMaxAngle);
void validateDegenerations();
void removeDuplicatedPoints();
void removeDuplicatedFacets();
void removeNonManifolds();
void removeSelfIntersections();
void removeFoldsOnSurface();
//@}
/** @name Python interface */

View File

@@ -165,6 +165,7 @@ PyObject* MeshPy::write(PyObject *args)
ext["NAS" ] = MeshCore::MeshIO::NAS;
ext["BDF" ] = MeshCore::MeshIO::NAS;
ext["PLY" ] = MeshCore::MeshIO::PLY;
ext["APLY"] = MeshCore::MeshIO::APLY;
ext["PY" ] = MeshCore::MeshIO::PY;
if (ext.find(Ext) != ext.end())
format = ext[Ext];

View File

@@ -66,7 +66,7 @@ libMeshGui_la_CPPFLAGS = -DMeshExport= -DMeshGuiExport=
libMeshGui_la_LIBADD = \
@BOOST_SIGNALS_LIB@ @BOOST_SYSTEM_LIB@ \
@GL_LIBS@ \
@GL_LIBS@ @ZIPIOS_LIB@ \
-lFreeCADBase \
-lFreeCADApp \
-lFreeCADGui \
@@ -146,6 +146,8 @@ EXTRA_DIST = \
Resources/translations/Mesh_nl.ts \
Resources/translations/Mesh_no.qm \
Resources/translations/Mesh_no.ts \
Resources/translations/Mesh_pl.qm \
Resources/translations/Mesh_pl.ts \
Resources/translations/Mesh_pt.qm \
Resources/translations/Mesh_pt.ts \
Resources/translations/Mesh_ru.qm \

View File

@@ -12,6 +12,7 @@
<file>translations/Mesh_it.qm</file>
<file>translations/Mesh_nl.qm</file>
<file>translations/Mesh_no.qm</file>
<file>translations/Mesh_pl.qm</file>
<file>translations/Mesh_pt.qm</file>
<file>translations/Mesh_ru.qm</file>
<file>translations/Mesh_se.qm</file>

View File

@@ -27,6 +27,8 @@
# include <QMenu>
# include <Inventor/SbBox2s.h>
# include <Inventor/SoPickedPoint.h>
# include <Inventor/actions/SoToVRML2Action.h>
# include <Inventor/VRMLnodes/SoVRMLGroup.h>
# include <Inventor/details/SoFaceDetail.h>
# include <Inventor/events/SoMouseButtonEvent.h>
# include <Inventor/nodes/SoBaseColor.h>
@@ -44,6 +46,7 @@
# include <Inventor/nodes/SoPolygonOffset.h>
# include <Inventor/nodes/SoShapeHints.h>
# include <Inventor/nodes/SoSeparator.h>
# include <Inventor/nodes/SoTransform.h>
#endif
/// Here the FreeCAD includes sorted by Base,App,Gui......
@@ -63,6 +66,7 @@
#include <Gui/SoFCOffscreenRenderer.h>
#include <Gui/SoFCSelection.h>
#include <Gui/SoFCSelectionAction.h>
#include <Gui/SoFCDB.h>
#include <Gui/MainWindow.h>
#include <Gui/Selection.h>
#include <Gui/Utilities.h>
@@ -82,6 +86,7 @@
#include <Mod/Mesh/App/Core/Visitor.h>
#include <Mod/Mesh/App/Mesh.h>
#include <Mod/Mesh/App/MeshFeature.h>
#include <zipios++/gzipoutputstream.h>
#include "ViewProvider.h"
#include "SoFCIndexedFaceSet.h"
@@ -484,6 +489,69 @@ std::vector<std::string> ViewProviderMesh::getDisplayModes(void) const
return StrList;
}
bool ViewProviderMesh::exportToVrml(const char* filename, const MeshCore::Material& mat, bool binary) const
{
SoCoordinate3* coords = new SoCoordinate3();
SoIndexedFaceSet* faces = new SoIndexedFaceSet();
ViewProviderMeshBuilder builder;
builder.createMesh(&static_cast<Mesh::Feature*>(pcObject)->Mesh, coords, faces);
SoMaterialBinding* binding = new SoMaterialBinding;
SoMaterial* material = new SoMaterial;
if (mat.diffuseColor.size() == coords->point.getNum()) {
binding->value = SoMaterialBinding::PER_VERTEX_INDEXED;
}
else if (mat.diffuseColor.size() == faces->coordIndex.getNum()/4) {
binding->value = SoMaterialBinding::PER_FACE_INDEXED;
}
if (mat.diffuseColor.size() > 1) {
material->diffuseColor.setNum(mat.diffuseColor.size());
SbColor* colors = material->diffuseColor.startEditing();
for (unsigned int i=0; i<mat.diffuseColor.size(); i++)
colors[i].setValue(mat.diffuseColor[i].r,mat.diffuseColor[i].g,mat.diffuseColor[i].b);
material->diffuseColor.finishEditing();
}
SoGroup* group = new SoGroup();
group->addChild(material);
group->addChild(binding);
group->addChild(new SoTransform());
group->addChild(coords);
group->addChild(faces);
SoToVRML2Action tovrml2;
group->ref();
tovrml2.apply(group);
group->unref();
SoVRMLGroup *vrmlRoot = tovrml2.getVRML2SceneGraph();
vrmlRoot->ref();
std::string buffer = Gui::SoFCDB::writeNodesToString(vrmlRoot);
vrmlRoot->unref(); // release the memory as soon as possible
Base::FileInfo fi(filename);
if (binary) {
Base::ofstream str(fi, std::ios::out | std::ios::binary);
zipios::GZIPOutputStream gzip(str);
if (gzip) {
gzip << buffer;
gzip.close();
return true;
}
}
else {
Base::ofstream str(fi, std::ios::out);
if (str) {
str << buffer;
str.close();
return true;
}
}
return false;
}
bool ViewProviderMesh::setEdit(int ModNum)
{
if (ModNum == ViewProvider::Transform)
@@ -1045,13 +1113,7 @@ void ViewProviderMesh::cutMesh(const std::vector<SbVec2f>& picked,
// Get the facet indices inside the tool mesh
std::vector<unsigned long> indices;
getFacetsFromPolygon(picked, Viewer, inner, indices);
// Get the attached mesh property
Mesh::PropertyMeshKernel& meshProp = static_cast<Mesh::Feature*>(pcObject)->Mesh;
//Remove the facets from the mesh and open a transaction object for the undo/redo stuff
meshProp.deleteFacetIndices(indices);
pcObject->purgeTouched();
removeFacets(indices);
}
void ViewProviderMesh::trimMesh(const std::vector<SbVec2f>& polygon,
@@ -1137,7 +1199,7 @@ void ViewProviderMesh::splitMesh(const MeshCore::MeshKernel& toolMesh, const Bas
// Remove the facets from the mesh and create a new one
Mesh::MeshObject* kernel = meshProp.getValue().meshFromSegment(indices);
meshProp.deleteFacetIndices(indices);
removeFacets(indices);
Mesh::Feature* splitMesh = static_cast<Mesh::Feature*>(App::GetApplication().getActiveDocument()
->addObject("Mesh::Feature",pcObject->getNameInDocument()));
// Note: deletes also kernel
@@ -1167,7 +1229,9 @@ void ViewProviderMesh::segmentMesh(const MeshCore::MeshKernel& toolMesh, const B
indices = complementary;
}
meshProp.createSegment(indices);
Mesh::MeshObject* kernel = meshProp.startEditing();
kernel->addSegment(indices);
meshProp.finishEditing();
static_cast<Mesh::Feature*>(pcObject)->purgeTouched();
}
@@ -1401,10 +1465,23 @@ void ViewProviderMesh::fillHole(unsigned long uFacet)
//add the facets to the mesh and open a transaction object for the undo/redo stuff
Gui::Application::Instance->activeDocument()->openCommand("Fill hole");
fea->Mesh.append(newFacets, newPoints);
Mesh::MeshObject* kernel = fea->Mesh.startEditing();
kernel->addFacets(newFacets, newPoints);
fea->Mesh.finishEditing();
Gui::Application::Instance->activeDocument()->commitCommand();
}
void ViewProviderMesh::removeFacets(const std::vector<unsigned long>& facets)
{
// Get the attached mesh property
Mesh::PropertyMeshKernel& meshProp = static_cast<Mesh::Feature*>(pcObject)->Mesh;
Mesh::MeshObject* kernel = meshProp.startEditing();
//Remove the facets from the mesh and open a transaction object for the undo/redo stuff
kernel->deleteFacets(facets);
meshProp.finishEditing();
pcObject->purgeTouched();
}
void ViewProviderMesh::selectFacet(unsigned long facet)
{
std::vector<unsigned long> selection;

View File

@@ -60,6 +60,7 @@ namespace Gui {
namespace MeshCore {
class MeshKernel;
struct Material;
}
@@ -122,6 +123,7 @@ public:
virtual void setDisplayMode(const char* ModeName);
/// returns a list of all possible modes
virtual std::vector<std::string> getDisplayModes(void) const;
bool exportToVrml(const char* filename, const MeshCore::Material&, bool binary=false) const;
/** @name Editing */
//@{
@@ -141,6 +143,7 @@ public:
std::vector<unsigned long> getFacetsOfRegion(const SbViewportRegion&, const SbViewportRegion&, SoCamera*) const;
std::vector<unsigned long> getVisibleFacetsAfterZoom(const SbBox2s&, const SbViewportRegion&, SoCamera*) const;
std::vector<unsigned long> getVisibleFacets(const SbViewportRegion&, SoCamera*) const;
virtual void removeFacets(const std::vector<unsigned long>&);
//@}
protected:

View File

@@ -26,6 +26,8 @@ EXTRA_DIST = \
translations/MeshPart_nl.ts \
translations/MeshPart_no.qm \
translations/MeshPart_no.ts \
translations/MeshPart_pl.qm \
translations/MeshPart_pl.ts \
translations/MeshPart_pt.qm \
translations/MeshPart_pt.ts \
translations/MeshPart_ru.qm \

View File

@@ -10,6 +10,7 @@
<file>translations/MeshPart_it.qm</file>
<file>translations/MeshPart_nl.qm</file>
<file>translations/MeshPart_no.qm</file>
<file>translations/MeshPart_pl.qm</file>
<file>translations/MeshPart_pt.qm</file>
<file>translations/MeshPart_ru.qm</file>
<file>translations/MeshPart_se.qm</file>

View File

@@ -247,6 +247,8 @@ EXTRA_DIST = \
Resources/translations/Part_nl.ts \
Resources/translations/Part_no.qm \
Resources/translations/Part_no.ts \
Resources/translations/Part_pl.qm \
Resources/translations/Part_pl.ts \
Resources/translations/Part_pt.qm \
Resources/translations/Part_pt.ts \
Resources/translations/Part_ru.qm \

View File

@@ -36,6 +36,7 @@
<file>translations/Part_it.qm</file>
<file>translations/Part_nl.qm</file>
<file>translations/Part_no.qm</file>
<file>translations/Part_pl.qm</file>
<file>translations/Part_pt.qm</file>
<file>translations/Part_ru.qm</file>
<file>translations/Part_se.qm</file>

View File

@@ -25,6 +25,8 @@ EXTRA_DIST = \
translations/PartDesign_nl.ts \
translations/PartDesign_no.qm \
translations/PartDesign_no.ts \
translations/PartDesign_pl.qm \
translations/PartDesign_pl.ts \
translations/PartDesign_pt.qm \
translations/PartDesign_pt.ts \
translations/PartDesign_ru.qm \

View File

@@ -12,6 +12,7 @@
<file>translations/PartDesign_it.qm</file>
<file>translations/PartDesign_nl.qm</file>
<file>translations/PartDesign_no.qm</file>
<file>translations/PartDesign_pl.qm</file>
<file>translations/PartDesign_pt.qm</file>
<file>translations/PartDesign_ru.qm</file>
<file>translations/PartDesign_se.qm</file>

View File

@@ -100,6 +100,8 @@ EXTRA_DIST = \
Resources/translations/Points_nl.ts \
Resources/translations/Points_no.qm \
Resources/translations/Points_no.ts \
Resources/translations/Points_pl.qm \
Resources/translations/Points_pl.ts \
Resources/translations/Points_pt.qm \
Resources/translations/Points_pt.ts \
Resources/translations/Points_ru.qm \

View File

@@ -9,6 +9,7 @@
<file>translations/Points_it.qm</file>
<file>translations/Points_nl.qm</file>
<file>translations/Points_no.qm</file>
<file>translations/Points_pl.qm</file>
<file>translations/Points_pt.qm</file>
<file>translations/Points_ru.qm</file>
<file>translations/Points_se.qm</file>

View File

@@ -118,6 +118,8 @@ EXTRA_DIST = \
Resources/translations/Raytracing_nl.ts \
Resources/translations/Raytracing_no.qm \
Resources/translations/Raytracing_no.ts \
Resources/translations/Raytracing_pl.qm \
Resources/translations/Raytracing_pl.ts \
Resources/translations/Raytracing_pt.qm \
Resources/translations/Raytracing_pt.ts \
Resources/translations/Raytracing_ru.qm \

View File

@@ -16,6 +16,7 @@
<file>translations/Raytracing_it.qm</file>
<file>translations/Raytracing_nl.qm</file>
<file>translations/Raytracing_no.qm</file>
<file>translations/Raytracing_pl.qm</file>
<file>translations/Raytracing_pt.qm</file>
<file>translations/Raytracing_ru.qm</file>
<file>translations/Raytracing_se.qm</file>

View File

@@ -26,6 +26,8 @@ EXTRA_DIST = \
translations/ReverseEngineering_nl.ts \
translations/ReverseEngineering_no.qm \
translations/ReverseEngineering_no.ts \
translations/ReverseEngineering_pl.qm \
translations/ReverseEngineering_pl.ts \
translations/ReverseEngineering_pt.qm \
translations/ReverseEngineering_pt.ts \
translations/ReverseEngineering_ru.qm \

View File

@@ -10,6 +10,7 @@
<file>translations/ReverseEngineering_it.qm</file>
<file>translations/ReverseEngineering_nl.qm</file>
<file>translations/ReverseEngineering_no.qm</file>
<file>translations/ReverseEngineering_pl.qm</file>
<file>translations/ReverseEngineering_pt.qm</file>
<file>translations/ReverseEngineering_ru.qm</file>
<file>translations/ReverseEngineering_se.qm</file>

View File

@@ -38,6 +38,8 @@ EXTRA_DIST = \
translations/Robot_nl.ts \
translations/Robot_no.qm \
translations/Robot_no.ts \
translations/Robot_pl.qm \
translations/Robot_pl.ts \
translations/Robot_pt.qm \
translations/Robot_pt.ts \
translations/Robot_ru.qm \

View File

@@ -22,6 +22,7 @@
<file>translations/Robot_it.qm</file>
<file>translations/Robot_nl.qm</file>
<file>translations/Robot_no.qm</file>
<file>translations/Robot_pl.qm</file>
<file>translations/Robot_pt.qm</file>
<file>translations/Robot_ru.qm</file>
<file>translations/Robot_se.qm</file>

View File

@@ -92,6 +92,8 @@ icons/Constraint_PointOnObject.svg \
translations/Sketcher_nl.ts \
translations/Sketcher_no.qm \
translations/Sketcher_no.ts \
translations/Sketcher_pl.qm \
translations/Sketcher_pl.ts \
translations/Sketcher_pt.qm \
translations/Sketcher_pt.ts \
translations/Sketcher_ru.qm \

View File

@@ -74,6 +74,7 @@
<file>translations/Sketcher_it.qm</file>
<file>translations/Sketcher_nl.qm</file>
<file>translations/Sketcher_no.qm</file>
<file>translations/Sketcher_pl.qm</file>
<file>translations/Sketcher_pt.qm</file>
<file>translations/Sketcher_ru.qm</file>
<file>translations/Sketcher_se.qm</file>

View File

@@ -11,6 +11,7 @@
<file>translations/StartPage_ru.qm</file>
<file>translations/StartPage_se.qm</file>
<file>translations/StartPage_uk.qm</file>
<file>translations/StartPage_pl.qm</file>
<file>translations/StartPage_pt.qm</file>
<file>translations/StartPage_hr.qm</file>
<file>translations/StartPage_zh.qm</file>

View File

@@ -77,14 +77,38 @@ EXTRA_DIST = \
CMakeLists.txt \
UnitTest.ui \
Resources/Test.qrc \
Resources/translations/Test_af.qm \
Resources/translations/Test_af.ts \
Resources/translations/Test_de.qm \
Resources/translations/Test_es.qm \
Resources/translations/Test_fr.qm \
Resources/translations/Test_it.qm \
Resources/translations/Test_se.qm \
Resources/translations/Test_de.ts \
Resources/translations/Test_es.qm \
Resources/translations/Test_es.ts \
Resources/translations/Test_fi.qm \
Resources/translations/Test_fi.ts \
Resources/translations/Test_fr.qm \
Resources/translations/Test_fr.ts \
Resources/translations/Test_hr.qm \
Resources/translations/Test_hr.ts \
Resources/translations/Test_hu.qm \
Resources/translations/Test_hu.ts \
Resources/translations/Test_it.qm \
Resources/translations/Test_it.ts \
Resources/translations/Test_ja.qm \
Resources/translations/Test_ja.ts \
Resources/translations/Test_nl.qm \
Resources/translations/Test_nl.ts \
Resources/translations/Test_no.qm \
Resources/translations/Test_no.ts \
Resources/translations/Test_pl.qm \
Resources/translations/Test_pl.ts \
Resources/translations/Test_pt.qm \
Resources/translations/Test_pt.ts \
Resources/translations/Test_ru.qm \
Resources/translations/Test_ru.ts \
Resources/translations/Test_se.qm \
Resources/translations/Test_se.ts \
Resources/translations/Test_uk.qm \
Resources/translations/Test_uk.ts \
Resources/translations/Test_zh.qm \
Resources/translations/Test_zh.ts \
qtunittest.py

View File

@@ -1,9 +1,21 @@
<RCC>
<qresource>
<file>translations/Test_af.qm</file>
<file>translations/Test_de.qm</file>
<file>translations/Test_es.qm</file>
<file>translations/Test_fi.qm</file>
<file>translations/Test_fr.qm</file>
<file>translations/Test_hr.qm</file>
<file>translations/Test_hu.qm</file>
<file>translations/Test_it.qm</file>
<file>translations/Test_ja.qm</file>
<file>translations/Test_nl.qm</file>
<file>translations/Test_no.qm</file>
<file>translations/Test_pl.qm</file>
<file>translations/Test_pt.qm</file>
<file>translations/Test_ru.qm</file>
<file>translations/Test_se.qm</file>
<file>translations/Test_uk.qm</file>
<file>translations/Test_zh.qm</file>
</qresource>
</RCC>