Commit Graph

145 Commits

Author SHA1 Message Date
wmayer
2303fd808a Part: apply OCC's fix for ElSLib::ConeDN and write a unit test 2022-05-27 14:44:35 +02:00
wmayer
2a5c875c6f Part: LGTM: Multiplication result may overflow 'int' before it is converted to 'unsigned int'. 2022-05-11 10:03:53 +02:00
wmayer
33cdb8c640 Part: implement persistence methods of all geometry classes and raise exception if needed (but no assert(0)) 2022-04-08 11:48:10 +02:00
0penBrain
3c6d6dfea5 [CrashFix] Core: fix crash when dumping content of a Surface 2022-04-08 10:55:31 +02:00
wmayer
6d2d45ceb7 Part: modernize C++11
* use nullptr
2022-03-23 19:26:14 +01:00
wmayer
135379e618 Part: issue #6488: Cone surface returns wrong dv derivative
This is a workaround to fix a bug in ElSLib::ConeDN
2022-03-01 14:59:26 +01:00
marioalexis
83b55e577b Part: Use Tools::getNormal to compute normal to surface 2022-01-20 13:01:27 +01:00
Ajinkya Dahale
ff2e246a55 [Part] Support insertion of knots in b-splines 2022-01-09 11:33:53 +01:00
Abdullah Tahiri
84898bd9a8 Part: Geometry and Sketcher: GeometryFacade and ExternalGeometryFacade
======================================================================

Change pass-by-value to const reference.

Thanks Kunda!

https://lgtm.com/projects/g/FreeCAD/FreeCAD/alerts/?mode=tree&ruleFocus=2163210742
https://forum.freecadweb.org/viewtopic.php?p=555658#p555658
2021-12-27 21:03:51 +01:00
Abdullah Tahiri
a16cbdc7a4 Part: Geometry - Curve member to calculate the normal at Point
==============================================================

Convenience member function combining closestParameter and normalAt using parameter.
2021-12-07 16:30:53 +01:00
Abdullah Tahiri
80f9793344 Part: Geometry - Extend Geometry Curve to query the value at parameter point directly from D0
=============================================================================================

Use the geometry specific D0 to calculate value at parameter point.
2021-12-07 16:30:53 +01:00
wmayer
a7f9c2f1b9 OCCT: port FreeCAD sources to version 7.6
SMESH is not yet ported
Although FreeCAD code compiles with OCCT 7.6 it doesn't work at the moment
2021-10-09 13:49:02 +02:00
Tomas Pavlicek
a7d83b5e15 Sketcher - Add new Split Edge action 2021-04-24 14:30:35 +02:00
Abdullah Tahiri
5ea99f4786 Part: Geometry - Add function to trim a B-Spline
================================================

Supports both non-periodic and periodic case
2021-03-21 06:56:23 +01:00
Abdullah Tahiri
6d0c845208 Part: Geometry - BSpline - fix weight assignment
================================================

If during assignment of weights (during the for loop iteratively setting the poles) all weights
become (temporarily) equal even though weights does not have equal values
OCCT will convert all the weights (the already assigned and those not yet assigned)
to 1.0 (nonrational b-splines have 1.0 weights). This may lead to the assignment of wrong
of weight values.

The work-around is to temporarily set the last weight to be assigned to a value different from
the current value and the to-be-assigned value for the weight at position last-to-be-assign but one.

Fixes:
https://forum.freecadweb.org/viewtopic.php?p=478701#p478702
2021-02-18 17:28:38 +01:00
Abdullah Tahiri
024283e704 Part: Geometry trigger notifyAttach on extension addition 2021-01-09 20:08:05 +01:00
Abdullah Tahiri
f7be6f5051 Part: Geometry - BSplineCurve - add IsRational member function 2020-12-19 11:58:54 +01:00
Abdullah Tahiri
8ffa978f3b Part/Sketcher: GeometryExtension/GeometryPersistentExtension split
==================================================================

GeometryExtension was originally designed to be serializable (save/restore). However,
GeometryMigrationExtension and ViewProviderSketchGeometryExtension have demonstrated the
usefulness of runtime-only GeometryExtensions.

The problem with runtime-only extensions being of a serializable type (GeometryExtension before
this commit) arises when Part::Geometry is to serialize the extensions and serialise the number
of extensions the geometry has. If runtime-only GeometryExtensions do not save a tag, then the
restore mechanism will expect more extensions that are actually in the XML file.

This commit makes GeometryExtension by default not serializable and deriving directly from
Base::BaseClass. A new class GeometryPersistentExtension is created, deriving from GeometryExtension
to provide serialisation. All Extensions requiring serialization derive from GeometryPersistentExtension
and those not requiring it from GeometryExtension directly.

This commit adapts all extensions to the new situation:
Part: GeometryDefaultExtension
Part: GeometryMigrationExtension
Sketcher: ViewProvierSketchGeometryExtension
Sketcher: SketchGeometryExtension and ExternalGeometryExtension
2020-12-10 18:34:06 +01:00
Abdullah Tahiri
994bd9d92b Part/Sketcher - Construction Migration - step 3: Removal of Geometry construction data member
=============================================================================================

This commits removes the Geometry construction data member and adapts sketcher code to use
GeometryFacade to access construction information via the SketchGeometryExtension.
2020-12-10 18:34:06 +01:00
Abdullah Tahiri
2c47b340bb Part: Geometry - Add non-const getters for extensions 2020-12-10 18:34:06 +01:00
Abdullah Tahiri
a15fd629e1 Part: Geometry refactor member copy
===================================

Encapsulate Part::Geometry data member copy process in a single function (copyNonTag).

Part::Geometry derived classes need not know the specifics of the data member of Part::Geometry.

Change the delegation of the copy of extensions from clone() to copyNonTag. Because clone() relies on
copy() and now copy() of Part::Geometry data member relies on copyNonTag(), there is no actual change
to the clone() functionality, but the copy() funcionality gains the copy of the extensions via copyNonTag().
2020-12-10 18:34:06 +01:00
wmayer
0e5cbf5298 Py2/Qt4: fix build failures and warnings 2020-11-30 19:05:37 +01:00
wmayer
f384202b93 Part: [skip ci] make arguments const references 2020-11-03 13:12:23 +01:00
Abdullah Tahiri
88e542b345 Part: Geometry extensions constness correction 2020-11-03 12:01:22 +01:00
Abdullah Tahiri
5c492f727c Part: Geometry - refactor py functions into class for code reuse 2020-11-03 12:01:22 +01:00
wmayer
eefa7dd798 Part: [skip ci] After removing a knot check if the B-spline is still valid 2020-10-30 13:55:31 +01:00
wmayer
e425a6bfe5 Part: [skip ci] handle OCCT exception in GeomBSplineCurve::copy() 2020-10-30 10:54:25 +01:00
wmayer
4fbc693014 Part: [skip ci] add method to approximate a B-spline curve with a given max. degree 2020-10-23 00:06:31 +02:00
wmayer
633fa6e3ac fixes #0004456: Regression : Part.Plane.Intersect do not accept plane as argument [skip ci] 2020-10-17 10:12:01 +02:00
wmayer
dcfbc1bf3b Part: [skip ci] replace some old C-style casts with static_cast 2020-10-17 10:10:44 +02:00
wmayer
904574d368 Part: expose GeomPlate algorithm to Python 2020-09-28 18:46:35 +02:00
wmayer
343639640c Part: converter from Adaptor3d_Curve to GeomCurve 2020-09-28 14:53:42 +02:00
wmayer
1a4c0a823d Part: [skip ci] add missing methods to RectangularTrimmedSurface 2020-09-28 13:18:47 +02:00
wmayer
1f8296736b Part: improve Python interface
+ rename getCurve2dFromGeom2d to makeFromCurve2d
+ add function makeFromCurve and makeFromTrimmedCurve like makeFromSurface
+ implement OffsetCurve.BasisCurve
+ fix memory leak in BRepOffsetAPI_MakePipeShellPy
2020-09-27 23:34:45 +02:00
wmayer
2c8f78b299 Part: [skip ci] return std::unique_ptr from Part::makeFromSurface() to avoid memory leaks 2020-08-29 23:56:12 +02:00
Abdullah Tahiri
71b54b7e46 Part: GeometryExtensions
========================

fixes #4087

Missing "break" in loop after finding the extension was causing segfault because of null pointer access, as the unique pointer had been std:move-d when found and was thus no longer valid.
2020-03-06 16:58:21 +01:00
asapelkin
ced8100ab9 use emplace_back instead of push_back where justified 2019-11-21 14:48:09 +01:00
wmayer
bbea71ce5f add missing std:: namespace to build on Debian 10 2019-08-21 19:22:01 +02:00
wmayer
7f4378a87e Fix clang compiler warnings:
+ fix -Winconsistent-missing-override
+ fix -Wpessimizing-move (Geometry::clone: moving a temporary object prevents copy elision -> remove std::move call here)
2019-08-17 19:52:32 +02:00
Abdullah Tahiri
331817d1b7 Part: Geometry extension set with unique id (type+name) and list based getExtensions python 2019-07-14 12:37:33 +02:00
Abdullah Tahiri
8618dfd3c6 Part Geometry: get an extension from type or name, also from python 2019-07-14 12:37:33 +02:00
Abdullah Tahiri
d8e99c1923 Part:: Geometry container extend hasExtension to type and name 2019-07-14 12:37:33 +02:00
Abdullah Tahiri
4d9d3b0c83 Part: Geometry - methods to remove extensions by name and type 2019-07-14 12:37:33 +02:00
Abdullah Tahiri
665fcda4dc Part: Fix assignment after reserve of weak_ptr causes segfault 2019-07-14 12:37:33 +02:00
Abdullah Tahiri
7488faa99f Part: Geometry extensions set interface
=======================================

unique_ptr is a move only type. Therefore it may only take an rvalue.

It does not make sense a pass by value for move only types (Item 41).
2019-07-14 12:37:31 +02:00
Abdullah Tahiri
e4aead2365 Geometry extensions: remove unnecessary smart pointer deletion
==============================================================

When the geometry object is destroyed, std::vector's destructor is called, which in turn calls the destructor of the smart pointers.

If a weak_ptr corresponding to one of those shared_ptr is locked (elsewhere, if FC were multithread),
the underlaying resource will not be freed until said locked weak_ptr goes out of scope. It will then.
2019-07-14 12:37:31 +02:00
Abdullah Tahiri
d082a42351 Part: Excise GeometryExtension from Geometry 2019-07-14 12:37:30 +02:00
Abdullah Tahiri
a96ca31dda Part:: Bug fix in geometry set extension 2019-07-14 12:37:29 +02:00
Abdullah Tahiri
55be6fdb7f Geometry Extension based on smart pointers 2019-07-14 12:37:28 +02:00
Abdullah Tahiri
41bf3fbf75 Geometry: Extensions - release any allocated dynamic memory 2019-07-14 12:37:28 +02:00