Commit Graph

406 Commits

Author SHA1 Message Date
David Carter
7e1b1abddd Materials: Change display of Quantity values
The default display type of quantity objects is fixed point resulting
in insufficient accuracy when changing unit systems, or when the values
are small. This fix changes the default format from 'Fixed' to the more
apt 'Default' format. This allows the displayed values to scale as
appropriate.

Fixes #18149
2024-12-20 11:31:43 -05:00
Benjamin Nauck
a2c980f7d6 Revert "Address the poor performance of the existing unique-name generation (#17944)"
This reverts commit 83202d8ad6.

# Conflicts:
#	src/Base/Tools.cpp
#	src/Base/Tools.h
2024-12-16 17:31:43 +01:00
Kacper Donat
aed305da64 Base: Add Services and ServiceProvider
This is intended to be used for intra-module communication. Modules can
specify service that are then implemented by other modules. This way
we can use features from for example part in Core without relying on the
Part module explicitly.

Base does provide Service definition - which is basically an abstract
class with pure virtual methods. This service then can be implemented
in other modules and accessed in runtime via ServiceProvider class that
stores all implementations.

ServiceProvider does store multiple implementations so in theory it is
possible to use it to provide granular implementations. For example,
part can provide CenterOfMass service that provides center of mass for
part features, mesh can implement another one for meshes and then we can
iterate over all implementations and find one that can provide center of
2024-12-13 12:01:13 -05:00
Kevin Martin
83202d8ad6 Address the poor performance of the existing unique-name generation (#17944)
* Address the poor performance of the existing unique-name generation

As described in Issue 16849, the existing Tools::getUniqueName method
requires calling code to form a vector of existing names to be avoided.

This leads to poor performance both in the O(n) cost of building such a
vector and also getUniqueName's O(n) algorithm for actually generating
the unique name (where 'n' is the number of pre-existing names).

This has  particularly noticeable cost in documents with large numbers
of DocumentObjects because generating both Names and Labels for each new
object incurs this cost. During an operation such as importing this
results in an O(n^2) time spent generating names.

The other major cost is in the saving of the temporary backup file,
which uses name generation for the "files" embedded in the Zip file.
Documents can easily need several such "files" for each object in the
document.

This update includes the following changes:

Create UniqueNameManager to keep a list of existing names organized in
a manner that eases unique-name generation. This class essentially acts
as a set of names, with the ability to add and remove names and check if
a name is already there, with the added ability to take a prototype name
and generate a unique form for it which is not already in the set.

Eliminate Tools::getUniqueName

Make DocumentObject naming use the new UniqueNameManager class

Make DocumentObject Label naming use the new UniqueNameManager class.
Labels are not always unique; unique labels are generated if the
settings at the time request it (and other conditions). Because of this
the Label management requires additionally keeping a map of counts
for labels which already exist more than once.
These collections are maintained via notifications of value changes on
the Label properties of the objects in the document.

Add Document::containsObject(DocumentObject*) for a definitive
test of an object being in a Document. This is needed because
DocumentObjects can be in a sort of limbo (e.g. when they are in the
Undo/Redo lists) where they have a parent linkage to the Document but
should not participate in Label collision checks.

Rename Document.getStandardObjectName to getStandardObjectLabel
to better represent what it does.

Use new UniqueNameManager for Writer internal filenames within the zip
file.

Eliminate unneeded Reader::FileNames collection. The file names
already exist in the FileList collection elements. The only existing
use for the FileNames collection was to determine if there were any
files at all, and with FileList and FileNames being parallel
vectors, they both had the same length so FileList could be used
for this test..

Use UniqueNameManager for document names and labels. This uses ad hoc
UniqueNameManager objects created on the spot on the assumption that
document creation is relatively rare and there are few documents, so
although the cost is O(n), n itself is small.

Use an ad hoc UniqueNameManager to name new DymanicProperty entries.
This is only done if a property of the proposed name already exists,
since such a check is more-or-less O(log(n)), almost never finds a
collision, and avoids the O(n) building of the UniqueNameManager.
If there is a collision an ad-hoc UniqueNameManager is built
and discarded after use.
The property management classes have a bit of a mess of methods
including several to populate various collection types with all
existing properties. Rather than introducing yet another such
collection-specific method to fill a UniqueNameManager, a
visitProperties method was added which calls a passed function for
each property. The existing code would be simpler if existing
fill-container methods all used this.
Ideally the PropertyContainer class would keep a central directory of
all properties ("static", Dynamic, and exposed by ExtensionContainer and
other derivations) and a permanent UniqueNameManager. However the
Property management is a bit of a mess making such a change a project
unto itself.

The unit tests for Tools:getUniqueName have been changed to test
UniqueNameManager.makeUniqueName instead.
This revealed a small regression insofar as passing a prototype name
like "xyz1234" to the old code would yield "xyz1235" whether or
not "xyz1234" already existed, while the new code will return the next
name above the currently-highest name on the "xyz" model, which could
be "xyz" or "xyz1".

* Correct wrong case on include path

* Implement suggested code changes
Also change the semantics of visitProperties to not have any short-circuit return

* Remove reference through undefined iterator

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix up some comments for DOxygen

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-12-13 10:54:46 -06:00
efferre79
fe57e3176d cmake fixes for external OndselSolver building (#18379)
* Assembly: fix building with external OndselSolver

This commit pairs with f35b075e271e9cb3451f3439f7dc0274841a0838.
It solves two issues:

- remove hardcoded includes of 3rdparty files
- add missing include_directories()

* Assembly: add check for external OndselSolver includes
2024-12-13 10:46:46 -06:00
marioalexis
a6b36f6e57 CMake: Decouple internal SMESH build from Fem build - fixes #18287 2024-12-09 12:09:30 -05:00
Chris Hennes
cdf6af935e Merge pull request #17315 from mwganson/ssclearall
[Spreadsheet] avoid removing user dynamic properties when clearing ce…
2024-12-06 11:57:45 -05:00
Ajinkya Dahale
f0f70daa0e [Sketcher][test] Add and use helper function to get points of interest 2024-12-04 00:57:41 +05:30
Ajinkya Dahale
263331f6fb [Sketcher] Refactor SketchObject::trim()
DO NOT MERGE because not complete: not all constraints are not transferred.

Includes:

* Adjust `deriveConstraintsForPieces` for trim
* Make sure new points are constrained on the cutting edges
* Add constraints at trim end(s) dependent on pre-exisiting ones with cutting curve(s). Also change tests to reflect that auto-coincidence can now be applied to non-periodic curves as well.

Known issue(s):
* Some redundant constraints may be added under certain circumstances (e.g. in
presence of perpendicular-via-point)
2024-12-04 00:57:40 +05:30
Ajinkya Dahale
b991c2fbc2 [Sketcher] Add tests for split and trim
Includes:
* Tests for splitting and trimming of various types of curves
* Assertions on constraints expected to be added on these curves
2024-12-04 00:57:40 +05:30
Ajinkya Dahale
311ac3591c [Sketcher][test] Add unit tests for SketchObject::getPoint() 2024-12-04 00:57:39 +05:30
wmayer
597e42d12f Test: Add unit test to read in 3MF file 2024-11-28 19:36:58 +01:00
Chris Hennes
e186920ad2 Spreadsheet: Add tests for validAddressName and validAliases 2024-11-26 17:51:57 -06:00
Jacob Oursland
fb7ce6405b CMake: Add missing target_link_directories() for OCCT. 2024-11-26 16:03:08 -05:00
Chris Hennes
12a648145a Spreadsheet: Add C++ test framework 2024-11-25 23:09:35 -06:00
wmayer
6f23f01e50 Tests: Add unit test for PR #16763 2024-11-22 12:05:30 +01:00
wmayer
2137dbc8d0 Tests: Add unit test for PR #16576 2024-11-22 12:02:30 +01:00
wmayer
a4bc06219b Tests: Add unit test to explore a null shape 2024-11-22 10:52:45 +01:00
wmayer
ffa3fa5b5a Core: Extend Color API
* Fix issues with alpha value <> transparency
* Use type traits to convert between different color classes (fixes #14515)
2024-11-15 12:25:25 -05:00
Eric Price
03cb520215 Part: bugfix #17468 recursively unpack compounds for boolean fuse (#17469)
* fix #17468  recursively unpack compounds for boolean fuse

* fix and into &&, add ctest case for multifuse with compounds and recursive compounds

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* remove unneeded duplicated code - allow Part::Common to be created with a single object (compound or shape) - will result in Unity and possibly a warning message

* prevent endless loop in case of endless recursive compounds as suggested in chat

* Update src/Mod/Part/App/FeaturePartFuse.cpp

Co-authored-by: Benjamin Nauck <benjamin@nauck.se>

* implemented suggestion by wwmayer

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Benjamin Nauck <benjamin@nauck.se>
2024-11-11 17:51:56 +01:00
wmayer
529779fb53 Test: Add unit test for pad 2024-10-26 15:39:04 +02:00
wmayer
062e11a3c8 Test: Add test for MeasureDistance with two circles 2024-10-23 23:07:49 +02:00
Eric Price
cf8ad66373 Fix boolean operations (#17119)
* add BRepAlgoAPI wrapper files to CMakeList

* introduce wrapper for BRepAlgoAPI_BooleanOperation and derivatives, set sensible default Fuzzyness for boolean operations

* allow default fuzzyness to be set in settings - including off

* backwards compatibility with OCCT 7.3.3 - removed newer paramateres from wrapper

* added missing header

* reverted src/Mod/Part/App/OpenCascadeAll.h to original state

* implement some changes suggested by @wwmayer

* removed unneeded destructor definitions

* moved getDefaultFuzzyValue into its own helper class

* removed unneeded references to base class default constructor

* default to SetRunParallel(Standard_True) as suggested by @FlachyJoe

* fixed license header as requested

* Added new method to autocalculate fuzzyness to BooleanOperation base class and use it for those parts that do not call the obsolete constructor but also do not set precision

* implemented static variable solution as suggested by @wwmayer

* added helix for test case

* Refactoring FCRepAlgoAPI to FCBRepAlgoAPI

* Added Test Case (fuse cylinder with helix with different working and non-working Fuzzy values)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* increased default value of FuzzyBoolean and made tests more robust for compatibility with OCCT 7.3

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fixes for FREECAD_USE_PCH - allow testing of FREECAD_USE_PCH on linux with cmake switch (default OFF)

* removed surplus line - wasn't needed after all

* included precompiled as instructed

* set anti-corruption flag in boolean operations, ensures source shape is not damaged in OCCT 7.1 and higher

* fix #17085

* disable subtests that were too specific for now

* fixed all CLI tests - see comments in Pull Request https://github.com/FreeCAD/FreeCAD/pull/17119#issuecomment-2420772452

* Update src/Mod/PartDesign/PartDesignTests/TestTopologicalNamingProblem.py

suggested updated test by CalligaroV

Co-authored-by: Vincenzo Calligaro <vincenzo.calligaro@gmail.com>

* Update tests/src/Mod/Part/App/TopoShapeExpansion.cpp

suggested updated test by CalligaroV

Co-authored-by: Vincenzo Calligaro <vincenzo.calligaro@gmail.com>

* Update tests/src/Mod/Part/App/TopoShapeExpansion.cpp

suggested updated test by CalligaroV

Co-authored-by: Vincenzo Calligaro <vincenzo.calligaro@gmail.com>

* Update tests/src/Mod/Part/App/TopoShapeExpansion.cpp

suggested updated test by CalligaroV

Co-authored-by: Vincenzo Calligaro <vincenzo.calligaro@gmail.com>

* Update tests/src/Mod/Part/App/TopoShapeExpansion.cpp

suggested updated test by CalligaroV

Co-authored-by: Vincenzo Calligaro <vincenzo.calligaro@gmail.com>

* Update tests/src/Mod/Part/App/TopoShapeExpansion.cpp

suggested updated test by CalligaroV

Co-authored-by: Vincenzo Calligaro <vincenzo.calligaro@gmail.com>

* Update tests/src/Mod/Part/App/TopoShapeExpansion.cpp

suggested updated test by CalligaroV

Co-authored-by: Vincenzo Calligaro <vincenzo.calligaro@gmail.com>

* Update tests/src/Mod/Part/App/TopoShapeExpansion.cpp

suggested updated test by CalligaroV

Co-authored-by: Vincenzo Calligaro <vincenzo.calligaro@gmail.com>

* Update tests/src/Mod/Part/App/TopoShapeExpansion.cpp

suggested updated test by CalligaroV

Co-authored-by: Vincenzo Calligaro <vincenzo.calligaro@gmail.com>

* Update tests/src/Mod/Part/App/TopoShapeExpansion.cpp

suggested updated test by CalligaroV

Co-authored-by: Vincenzo Calligaro <vincenzo.calligaro@gmail.com>

* Update tests/src/Mod/Part/App/TopoShapeExpansion.cpp

suggested updated test by CalligaroV

Co-authored-by: Vincenzo Calligaro <vincenzo.calligaro@gmail.com>

* Update tests/src/Mod/Part/App/TopoShapeExpansion.cpp

suggested updated test by CalligaroV

Co-authored-by: Vincenzo Calligaro <vincenzo.calligaro@gmail.com>

* Update tests/src/Mod/Part/App/TopoShapeExpansion.cpp

suggested updated test by CalligaroV

Co-authored-by: Vincenzo Calligaro <vincenzo.calligaro@gmail.com>

* Update tests/src/Mod/Part/App/TopoShapeExpansion.cpp

suggested updated test by CalligaroV

Co-authored-by: Vincenzo Calligaro <vincenzo.calligaro@gmail.com>

* Update tests/src/Mod/Part/App/TopoShapeExpansion.cpp

Co-authored-by: Vincenzo Calligaro <vincenzo.calligaro@gmail.com>

* remove surplus tests from github suggestion interface bug

* hide the BooleanFuzzy variable - can now be only set by manually editing the config file
i
in FCParamGroup "Boolean"
<FCFloat Name="BooleanFuzzy" Value="10.000000000000"/>

* Suggestion by @FlachyJoe - add validity checks to the base and tool shape in any direct boolean op

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Vincenzo Calligaro <vincenzo.calligaro@gmail.com>
2024-10-21 18:38:51 +02:00
Kris Wilk
ffa1189634 Prevent using reserved names for properties or aliases (Fix #16846) (#16902)
* Prevent naming properties with reserved words (Fix #16846)

* Prevent using reserved constant names for properties or aliases

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* App: Add unit test for isTokenAConstant

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Chris Hennes <chennes@pioneerlibrarysystem.org>
2024-10-03 10:03:10 -05:00
huguesdpdn-aerospace
3795904a00 PD: Xerces-C++ - Prepare for the latest version (backward compatible) 2024-09-08 20:31:25 -05:00
bgbsww
3a6f70946a Fix #16013 (#16090)
* Fix #16013

* Fix #16013
2024-09-02 18:00:47 +02:00
bgbsww
2a541c9536 Toponaming: Remove remaining FC_USE_TNP_FIX defines 2024-08-31 13:21:10 -05:00
bgbsww
ecf7e51ab3 Toponaming: Remove all FC_USE_TNP_FIX protected old code 2024-08-26 11:12:48 -05:00
pre-commit-ci[bot]
9d949c60aa [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2024-08-25 07:29:42 +00:00
CalligaroV
cbbc08fc47 Part/Toponaming: use TopoShape::getShape() in PartFeatures.cpp tests and TopoShapeMakeElementRefine.cpp tests
* Replace TopoShape::getValue() with TopoShape::getShape() to test the size of element maps
 * Update the expected values

Signed-off-by: CalligaroV <vincenzo.calligaro@gmail.com>
2024-08-24 19:54:33 -05:00
bgbsww
f0982d1d61 Toponaming: Fuse call makeElementRefine; remove deprecated refineSha… (#15897)
* Toponaming:  Fuse call makeElementRefine; remove deprecated refineShapeIfActive
* Part/Toponaming: import code for MultiFuse::execute() from LS3
* added expected values of testRefine

Co-authored-by: Zheng, Lei <realthunder.dev@gmail.com>
Co-authored-by: CalligaroV <vincenzo.calligaro@gmail.com>
Co-authored-by: Chris Hennes <chennes@pioneerlibrarysystem.org>
2024-08-18 11:49:05 -05:00
bgbsww
a1ce983035 Toponaming: Missing shape hasher line; fixed cleaned Transformed 2024-08-13 07:07:59 -04:00
bgbsww
71870bd6f3 Toponaming: Touchup cleanup
Includes some header re-ordering from chennes.
2024-07-26 21:39:39 -05:00
bgbsww
e15646d158 Toponaming: Tests, cleanup, and fix axis drawing 2024-07-26 11:49:56 -04:00
wmayer
61c964caa9 MSVC: Suppress warning 2024-07-25 20:34:52 +02:00
wmayer
8deb2e0f0f MSVC: Fix compiler warning 2024-07-25 20:08:10 +02:00
bgbsww
0178e848e4 Toponaming: Clean code, apply remark recommendations and Tweak tests 2024-07-22 12:55:23 -04:00
Chris Hennes
dd86f21130 Merge pull request #15521 from bgbsww/bgbsww-toponamingSaveRestore1plus
Throw exceptions rather than return default 0
2024-07-22 10:46:53 -05:00
wmayer
373533d030 Tests: Add tests for MeshPart 2024-07-22 00:06:23 -05:00
bgbsww
0bddc51805 Refactor all element name pairs into clearer struct names - renames 2024-07-20 16:32:12 -04:00
bgbsww
178c4ec477 Throw exceptions rather than return default 0 2024-07-19 09:09:59 -04:00
bgbsww
63a68b3c1c Throw exceptions rather than return default 0 2024-07-19 08:59:25 -04:00
wmayer
b0676d0578 Tests: Fix warnings: unknown pragma ignored [-Wunknown-pragmas] 2024-07-12 21:53:53 +02:00
bgbsww
5568b40a07 Toponaming: Add missing TNP element name code; rough in more TNP tests (#14561)
* Add missing TNP element name code; rough in more TNP tests

* Update ElementNamingUtils.cpp

---------

Co-authored-by: Chris Hennes <chennes@pioneerlibrarysystem.org>
2024-07-08 18:43:42 -05:00
Chris Hennes
2411f9f3b3 Merge pull request #14461 from AjinkyaDahale/sk-fix-12592-bsp-by-knot-trim
[Part][Sketcher] Fix some B-spline trimming issues
2024-07-01 11:28:50 -05:00
CalligaroV
8def1e94dc Part/Toponaming: makeElementWires
* Updated tests

Signed-off-by: CalligaroV <vincenzo.calligaro@gmail.com>
2024-06-26 10:46:36 -05:00
Ajinkya Dahale
16cc6bf56a [Part][test] Add tests for GeomBSplineCurve::Trim() 2024-06-24 21:56:58 +05:30
Chris Hennes
d01ce32a1f Update for LibPack3 (#10337)
* cMake: Add base support for LibPack3

Minor changes to FreeCAD source code to support compiling with Qt 6.5 on MSVC,
and changes to cMake setup to support the new Libpack.

* NETGENPlugin: Fix compilation with MSVC and OCCT 7.8

* Material: Switch to Wrapped_ParseTupleAndKeywords for /fpermissive- on MSVC

* Base: Prevent accidental definition of MIN and MAX by MSVC

* cMake: Prevent accidentally finding an old LibPack

* Material: Wrap another ParseTuple call

* OCCT: Modify includes for 7.8.x

* Part: Change TNP code to use Wrapped_ParseTupleAndArgs

* Spreadsheet: Workaround for MSVC macro pollution

* Mesh: Workaround for MSVC macro pollution

* Base: Remove extra MSVC flag (moved to CMake)

* Tests: Fix compiling with /permissive-

* FEM: Fix Qt warnings about duplicate element names

* cMake: Ensure major version numbers are set

* Address review comments.

* cMake: Further tweaks for LibPack3

* cMake: Modify specification of compiler flags for MSVC

* Main: Remove QtQuick testing code

* cmake: Find Boost before SMESH (which uses it)

* Fixes for LibPack2

* cMake: Another try at importinhg VTK cleanly
2024-06-24 18:25:05 +02:00
wmayer
2f8382ae59 MSVC: Fix compiler warnings
* avoid redefines in Assembly
* explicit cast from size_t to int
* remove unused variables
* avoid implicit cast from double to float
* in test cases replace EXPECT_FLOAT_EQ with EXPECT_DOUBLE_EQ or EXPECT_NEAR when doubles are used
2024-06-20 15:42:16 -05:00
Mihail Dumitrescu
417e6559b4 Add ParallelPlane attachment mode.
It results in an attachment similar to ObjectXY but with the XY plane translated to pass through a selected vertex.

It is most useful to place sketches: pick a plane (XY, XZ, YZ) or another sketch then select a vertex to automatically translate the sketch in the Z-direction. In contrast to the Translate mode it does not change the origin.
2024-06-10 10:47:00 -05:00