1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-19 13:40:49 +03:00

Compare commits

..

74 Commits

Author SHA1 Message Date
dpasukhi
c975787c6c 0033404: Configuration - Building with Cotire failed on Clang-15
Replaced old including of int defs from C standard into C++(11+) standard
2023-06-06 13:21:50 +00:00
dpasukhi
6aa053ae00 0033391: Coding - Clearing old definition way for strcasecmp
Removed artifacts for strcasecmp definitions
2023-05-31 20:17:31 +01:00
dpasukhi
54ed243582 0033372: Visualization - Compilation of git master fails against vtk 9.2.6
Fixed compilation on vtk 9.2.6.
Resolved name collisions with X11 headers
2023-05-31 20:07:16 +01:00
akaftasev
8748042259 0033390: Coding - Debug version of OCCT does not compile
Deleted code for OCCT_DEBUG was returned and added under macros OCCT_DEBUG
2023-05-22 12:00:32 +01:00
dpasukhi
92e0a76a50 0033379: Coding - Processing Clang-15 warnings
Fixed warning generated by Clang++-15
2023-05-19 19:34:37 +01:00
dpasukhi
b2fedee6a1 0033375: Coding - Static Analyzing processing. Performance
Performance update applied:
  - moving to const reference as much as possible
Result of CLANG_TIDY (static analyzing filter: perform*)
2023-05-19 19:33:59 +01:00
akaftasev
c28dd7f1cf 0033361: Modeling Algorithm - Fuse operation generates incomplete result
Added additional check of Face-Face intersection to avoid missing section edges because of sequence of Face-Face interference processing
2023-05-18 22:48:45 +01:00
dpasukhi
c36205a05e 0033378: Configuration - Moving ExpToCas into separate module
Moved ExpToCasExe and its DLL to new module - DETools
Created new module - DETools to keep tools to DE
Changed definition of main of ExpToCasExe to not const parameter
FlexLexer.h moved to general location into TKernel
2023-05-18 22:48:02 +01:00
ichesnok
945e309564 0030066: Data Exchange - Fail to load VRML from ArcGIS
Fixed VrmlData_Scene::readHeader method
2023-05-17 21:47:01 +01:00
ichesnok
e3841f9ffe 0033318: Data Exchange - Modifying the BRep flag after exporting the shape
Fixed condition for setting 'checked' flag
2023-05-17 21:46:06 +01:00
anv
bcfc5f0d5a 0033369: Modeling Algorithms - BRepBuilderAPI_Transform makes invalid shape after transformation
Added check to avoid setting parametric boundaries to infinity.
2023-05-17 21:45:13 +01:00
dpasukhi
c3f6267d24 0033382: Configuration - Installation issue for debug mode for static build
Updated install command to handle BUILD_SHARED_LIBS configuration
2023-05-16 13:48:11 +01:00
dpasukhi
5d8b1a4076 0033350: Data Exchange, Step Import - Improving parsing performance
Improved performance of parser by disable checking for eof (20% parsing time)
Changed step parser's record to keep last one to fast insert into end.
2023-05-14 21:40:28 +01:00
dpasukhi
e4f00dbb7e 0033377: Data Exchange - STEPCAFControl_Reader crash in OCC 7.7.0
Added checking for null object for STEPCAFControl_Reader::SettleShapeData
2023-05-10 19:29:14 +01:00
msmediasofts
359edc7d8a 0033366: Documentation - Add description of BRepAlgoAPI_Algo::Shape()
Added description of BRepAlgoAPI_Algo::Shape()
2023-04-19 18:04:52 +01:00
mzernova
f9998f03ad 0031777: Visualization - improve SelectMgr_EntityOwner to process selection scheme
The selection scheme has been propagated to Owner object interface, and the
AIS_Selection::Select() method has been replaced to unify the logic.
2023-04-05 17:20:33 +01:00
dorlov
c479c4f6d8 0023638: Data Exchange - Reading IGES file produced invalid shape
Removed double healing of Iges group entities
Added ShapeBuild_ReShape member to the IGESData_IGESModel class, shapes which are registered in ShapeBuild_ReShape class does not process to healing
2023-03-28 01:00:42 +01:00
dpasukhi
c51df6bfd2 0033327: Data Exchange, IGES Import - SubfigureDef can't read string
Fixed problem with texted types
Added checking for null string for subfigure via XCAF transferring
2023-03-20 23:11:36 +00:00
dpasukhi
5e43274280 0033337: DRAW - Can't load plugins on Linux OS
WSL 2 have windows FileSystem and as a result we have \r symbols before \n
For this cases we can just remove \r\n (\n is a last symbol) for the node value.
2023-03-20 23:11:35 +00:00
dpasukhi
efe960751c 0033331: Data Exchange, Step Import - Unsupported Representation Items
Fixed problem with iteration on Null RI
2023-03-20 23:11:27 +00:00
anv
6b9e0dc3f8 0033345: Coding - Memory allocation operators got inaccessible
Macros was moved back to public.
2023-03-19 20:53:54 +00:00
akaftasev
2ef94c994e 0033340: Modeling Algorithm - Improve memory management performance in the PaveFiller
Changed NCollection_BaseAllocator to NCollection_IncAllocator in BOPAlgo_PaveFiller::MakeBlocks()
2023-03-19 20:53:53 +00:00
dpasukhi
1dd4b902c0 0033092: Data Exchange, Documentation - Implementation of DE_Wrapper documentation
Implement new user-guide documentation for DE Wrapper
2023-03-19 20:53:53 +00:00
akaftasev
a846d36326 0033264: Modeling Algorithms - Result of section operation is incomplete
Test case added.
2023-03-19 20:53:53 +00:00
akaftasev
86e352849d 0033263: Modeling Algorithms - BRepFilletAPI_MakeFillet doesn't work for current parameters
Do not calculate edge state if there are more than 4 G1 connections for currect vertex.
2023-02-10 15:35:41 +00:00
akaftasev
6d140acb14 0030292: Modeling Algorithms - BRepBndLib should avoid using Poly_Polygon3D when called with useTriangulation set to false
BRepBndLib.cxx : treatment of useTriangulation is modified according to specified behavior of algorithm
BRepTest_CurveCommands.cxx : creation edge from polygon3d is added in Draw command mkedge.
2023-02-06 17:51:52 +00:00
akaftasev
44be123039 0030055: BRepOffset_MakeOffset throws "TopoDS_Vertex hasn't gp_Pnt" in intersection mode
Diagnostic of mixed connectivity of faces along common edge is added.
If algorithm finds such pair of faces, it stops working with special error code.
2023-02-06 14:15:35 +03:00
dpasukhi
47263fa6a3 0033317: Data Exchange, Step Export - Ignoring color attached to the reference shape label
Fixed problem with pure referencing.
  To export reference label to step we convert it to the assembly with one part.
  All attributes attached to the label should be moved to the new part.
  For working with it new map contains only pure reference labels, that converted to the part
  was implemented to the STEPCAFControl_Writer.
Updated code style of the STEPCAFControl_Writer
Improved ability to export labels from different documents
Removed OCCT_Debug macros to print in Trace gravity
2023-02-04 09:18:29 +00:00
mzernova
b0afa94d10 0027848: Visualization - sensitivity of lines is too high
Improved objects sorting by depth.

The sensitivity calculation for the manipulator has been changed.
Now the sensitivity of the elements of the manipulator depends on its size.

Also fixed the problem of erroneous selection of unfilled circles (SelectMgr_Frustum<N>::hasCircleOverlap() function).

Test case vselect/bugs/bug27848 added.
2023-02-04 09:17:58 +00:00
dorlov
c772c6caa4 0030828: Data Exchange - The commands getting shapes from XCAF document should be available in C++
Added two new overloaded methods XCAFDoc_ShapeTool::GetOneShape: one returns TopoDS_Shape from TDF_LabelSequence and the other from a sequence of all top-level shapes which are free
2023-02-02 15:04:50 +00:00
mzernova
53eae1a935 0032570: Visualization, AIS_AnimationObject - define rotation around axis
When using AIS_AnimationObject, linear interpolation is performed from one gp_Trsf transformation to another.
But when an object rotates around a specific axis, the object moves not along a linear trajectory,
but along a circle. Therefore, a separate class AIS_AnimationAxisRotation was created that
allows to animate rotation around a specific axis.

Test case tests/v3d/bugs/bug32570 was added.
2023-02-01 23:26:46 +00:00
dpasukhi
d22b135217 0033307: Data Exchange, Step Import - Crash after reading empty edge loop
Fixed problem with empty edge list in the edge loop, mark as a fail entity in this case
2023-02-01 00:09:26 +00:00
vro
3c7c705d77 0033320: Data Exchange - Reading of a VRML file with a long line fails
Implement rolling back input stream to split on possible logical parts by comma or space.
2023-01-24 22:38:57 +00:00
dorlov
fc72568ba9 0033312: Data Exchange - NULL-dereference in StepToTopoDS_TranslateShell::Init()
The condition "if" was changed to opposite
2023-01-20 03:10:45 +00:00
akaftasev
107b57a955 0033311: Modeling Algorithm - No results of thrusection algorithm
Changed default value of myPercent
2023-01-17 20:47:54 +00:00
oan
8b301eb865 0033315: Mesh - BRepMesh_IncrementalMesh takes forever to finish (ends up with system memory, etc)
Added test case
2023-01-16 22:00:35 +00:00
rodrlyra
1f469e3781 0033305: Coding - BOPTools_PairSelector::Clear method uses "Clear" instead of "clear" on std::vector 2023-01-16 15:22:08 +00:00
akaftasev
ce4d294074 0033306: Modeling Algorithm - Crash in TrimEdge() method
Added condition to not cut the edges by closely located parameters
2023-01-09 21:44:11 +00:00
akaftasev
9f338a00a1 0033298: Modeling Algorithm - Offset operation gives wrong result
Process only those images of the faces, if one if them has anInsideEdges/anInsideVertices and the other is not.
2023-01-03 18:01:14 +00:00
akaftasev
a011359b8a 0033227: Modeling Algorithm - BOPAlgo_BuilderSolid generates incomplete result
Deleted outer loop for shells.
Added additional check of edges orientation for RefineShell().
2023-01-03 18:01:05 +00:00
msv
42e4ae96ae 0033304: Modeling Data - Floating point signal when converting a B-spline curve to analytical form
Protect the static function ConicDefinition from calling sqrt with negative argument.
2023-01-03 18:00:55 +00:00
akaftasev
686926c0a9 0033247: Modeling Algorithm - BOP report small edges problem and produce empty result
Build shifted pcurve for ellipse and circle cases.
2022-12-22 16:20:54 +00:00
akaftasev
a638dd6224 0033265: Modeling Algorithms - Boolean operation hangs on the attached shapes
Added test case.
2022-12-16 14:28:08 +00:00
ifv
961a306dc4 0033244: Modeling Algorithms - Surface-surface intersection produces the double curves
IntAna_QuadQuadGeo.cxx - estimation of angular tolerance is added for case cone-cone

tests/lowalgos/intss/bug33244 - new test case added
2022-12-12 10:27:10 +03:00
ifv
195a068c4f 0030781: Sweep algorithm creates non-planar edges (orig. BOPAlgo_MakerVolume fails to build a solid)
BRepFill/BRepFill_AdvancedEvolved.cxx - estimation of angular tolerance is added in method GetLids()

tests/evolved/voluved/bug30781 - new test added
2022-12-10 14:04:53 +00:00
dpasukhi
669e0dfc17 0033246: Data Exchange, DE Wrapper - Checking license leads to performance problem
ReWork UpdateLoad functionality:
UpdateLoad calls only if provider is found.
UpdateLoad calls only for chosen type of translation (read/write)
Add new method to UpdateLoad all registered nodes.
2022-12-10 14:02:56 +00:00
nunomsil
74cb5673a5 0031919: Modeling Algorithms - General Fuse raises exception on attempt to imprint a contour to a shell
Exception no longer occurs in current version. However, fuzzyvalue should be set to 1 for the result of the operation to make sense (result of common is 1 wire). Test case added
2022-12-07 14:45:36 +00:00
dpasukhi
768f3a4a19 0033235: Configuration - Solving the problem with static building of ExpToCasExe
Added new dependency to ExpToCasExe - CSF_wsock32 (on Win only)
2022-12-04 13:49:06 +03:00
dpasukhi
2a8c5ad46c 0033250: Configuration - Missing Limits header file
Added new include limits to fix build problem
2022-12-04 13:48:24 +03:00
stv
7ea3eff4f8 0033218: Data Exchange - XCAFPrs_Texture not allow to use classes inherited from Image_Texture
Type of field XCAFPrs_Texture::myImageSource was changed from Image_Texture to Handle(Image_Texture)
2022-12-04 13:47:36 +03:00
dpasukhi
c07f4ee70d 0033232: Data Exchange, DE_Wrapper - Implement ability to change global session
Add ability to set/get global session
2022-12-04 13:46:38 +03:00
dpasukhi
6cc679d81c 0033230: Data Exchange, DE Wrapper - Update API to find CAD provider
Moved FindProvider method to public section
Made FindProvider as virtual to make it possible to overwrite.
2022-12-04 13:46:38 +03:00
dpasukhi
62f554bc3f 0033228: Data Exchange, DE Wrapper - Make the document argument of the method Read const handle
Rewrite document argument for DE_Wrapper Read method
2022-12-04 13:46:37 +03:00
sshutina
7eeb5d5fbf 0032965: PMIVis - PMIVis_TOT_Vectorized text regressions
Added the ability to draw a shaded shape in the required group.
2022-12-04 13:44:52 +03:00
oan
9b7f1aea28 0031865: Mesh - triangulation fails with large deflection values due to unhandled Standard_OutOfRange, BRepMesh_PairOfIndex::Append()
Define minimum number of points for specific types of curves like it was done for circular edges.
2022-12-04 13:43:52 +03:00
knosulko
1e96cf65fa 0033156: Modeling Algorithms - Planar face creation problem
BRepLib_MakeFace::BRepLib_MakeFace: deleted degenerative edges from the input wire;
add test tests\mkface\mkplane\bug33156.
2022-12-04 13:42:28 +03:00
ddzama
03275c0be1 0022821: Crash with BRepFilletAPI_MakeFillet
test bugs modalg_7 bug22821 failed on fillet shape with 5-th edge.
Experimentally has been found that reducing of parameter
ChFi3d_Builder::tolesp for this task solves the issue.

So, as soluton it is proposed to link parameter toleps with parameter range of
spine curve. So, production coefficient has been set to pass all tests and
2 teset was extended: tests/blend/complex/A6, tests/bugs/modalg_7/bug22821

first has been extended to test different scaling factors,
second has been extended to make fillet on all edges from 12.

Additionally:
 - fixed misusage of tolesp in contexts where tolerance of point in 3d is excepted;
     In some context usage of tol_esp is irrelevant, because its essentiality - tolerance of the parameter on the 3d curve.
     So, in such context it has been replaced with new parameter tol3d (with fix value 1.0e-4).
     Get rid of tolapp3d duplication constant - tol_3d
 - tolesp = 5.0e-5 * (umax - umin)
 - tolesp replaced by tolpoint2d/tolpoint3d in several classes.
     Blend_Walking
     BRepBlend_SurfRstLineBuilder
     BRepBlend_RstRstLineBuilder
     Blend_CSWalking
     Instead `tolesp` - `tolgui` is employed in contexts where tolerance of guide curve parameter is excepted.
     Instead `tolesp` - `tolpoint2d` or `tolpoint3d` is employed in contexts where tolerance of point in 2d or 3d space is excepted.
 - Replace tolesp with tolpoint2d/tolpoint3d in BBPP function argument.
 - Use tolapp3d instead tolesp in BonVoisin function,
2022-12-04 13:41:29 +03:00
ddzama
2f33e34038 0032934: Modelling Algorithms - BRepExtrema_DistShapeShape returns two solutions instead of one
distmini of two edges returns two solution points instead one.
Second unneeded solution point is the same as first.

The problem was in fact that second edge has continuity C0.
In this case additional extremas analysis performed in special procedure

PERFORM_C0

And second point found in this procedure.
Folowing code of

BRepExtrema_DistanceSS::Perform (variant for Edge/Edge)

we should this additional solution extremas set
to be object of test TRI_SOLUTION before pushing
into main list of solution.
This solves the problem.
Corresponding test and compound with edges has been created.

Additionally, in the function

PERFORM_C0

an obvious error has fixed.
2022-12-04 13:39:35 +03:00
akaftasev
3eb891ec49 0033180: We had a problem calling the OCC library at the customer site, and the program crashed
Added status for thrusection operations and changed throw constructions to set of the status and break the function.
2022-12-04 13:35:24 +03:00
smoskvin
057dcfddf7 0033225: Changing the status of tests on Ubuntu 20.04 and Windows 64 VC142 2022-11-28 00:04:06 +03:00
atereshi
3837b3bf28 0033217: DRAW - Missed Standard_EXPORT attribute in DrawTrSurf_Set* functions 2022-11-25 13:03:27 +03:00
gelin
db2bfd1e83 0032818: Modeling Algorithms - Result of sweep operation is invalid
BRepFill_TrimShellCorner.cxx - setting correct orientation for NewEdge
tests/pipe/bugs/bug32818 - new test case added
2022-11-21 20:13:47 +03:00
ika
a855215141 0030256: ACIS Import - crash while importing SAT file on constructing a pipe
Fix for thin section with both first and last parameters located in one segment.
2022-11-21 20:11:13 +03:00
ifv
195aac3a42 0033193: Modeling Algorithms - Regression: UnifySameDomain raises SIGSEGV
ShapeUpgrade_UnifySameDomain.cxx - method ReconstructMissedSeam is improved.

tests/bugs/heal/bug33193 - new test case added
2022-11-21 20:10:06 +03:00
atereshi
f706dd34b3 0027122: Data Exchange - invalid shapes are produced during model translation due to huge face tolerance
Problem: The shape has two faces that dimensions are less than tolerance in the specified STEP file. This situation produces the invalid shape.
Change: Shape process has operator FixFaceSize, that is exactly suitable for this shape. The only option of FixFaceSize operator was added to InterfaceStatic, to manage the operator from DRAW command.
Result: The shape without artifacts can be reproduced from STEP file with an extra healing procedure.
2022-11-21 20:06:04 +03:00
ifv
c325231de6 0033179: Modeling Algorithms - Crash in ShapeFix_Shape with the attached object, when healing for fixing SameParameterFlag
BSplCLib_2.cxx - method MergeBSplineKnots is modified in order to have always not empty result.
Geom2dConvert.cxx - in static function MultNumandDenom tolerance for comparing knots is decreased.

tests/bugs/modalg_8/bug33179 test case added
2022-11-21 20:03:35 +03:00
ifv
91a2f58f8f 0026441: Modeling Algorithms - BRepOffset_MakeOffset affects original shape
BRepOffset_MakeOffset.cxx - tolerance control for building planar faces is implemented,
                            updating tolerance for initial entities is avoided

BRepAlgo_Loop.cxx - "total" setting tolerance 0.001 is removing

BRepLib.cxx - checking of "locked" for vertex is removing in static function UpdShTol

QABugs_20.cxx - add new command OCC26441 for checking tolerance differenses between two "identical" shapes

tests/bugs/modalg_7/bug30054 - case now is "BAD", because really result shape is invalid: many faces has not closed wires with huge gaps between ends of edges. Result was "OK" only because tolerances of vertices were increased by algorithm to cover all gaps.

tests/bugs/modalg_8/bug26441 - new test case added

Other test: B3, C8, A7, C8: they were "BAD" and now are "BAD", only some problems are changed.
2022-11-21 20:00:23 +03:00
ifv
8175a70c4e 0033173: Modeling Algorithms - Regression in BRepExtrema_DistShapeShape causing Standard_OutOfRange exception
Extrema/Extrema_ExtCC.cxx - checking number of solutions is added

tests/bugs/modalg_8/bug33173 - test case added
2022-11-21 19:57:45 +03:00
atereshi
f9990707fe 0033187: Modeling Algorithms - Crash in postprocessing of imported shape
Problem: Desynchronization of behaviors of GeomAdaptor_Curve::NbIntervals and
 GeomAdaptor_Curve::Intervals functions. First calculates number of intervals, then
 array is created and second fills the array. In some cases the size of array
 is less than need for filling.

Change:
1. Added function BSplCLib::Intervals that calculates number of interval and fills
 the array with its (if needed).
2. Simplified the algorithm of intervals calculation.
3. GeomAdaptor_Curve::NbIntervals/Intervals and Geom2dAdaptor_Curve::NbIntervals/Intervals
 use BSplCLib::Intervals.
4. When creating an adapter for the base curve, the boundaries of the adapter for the offset curve are applied.
5. Test for problem shape was created: bugs modalg_8 bug33187.

Result: The new approach eliminates the problem of writing outside the array bounds.
2022-11-21 19:53:59 +03:00
knosulko
aba5c241c6 0033144: Modeling Algorithms - Wrong result of Shape Proximity
Added step of refinement the coarser of the two shapes meshes to produce two meshes with approximately the same density.
Added tests lowalgos/proximity.

Fixed accounting of parameters to adjust number of initial sample points
2022-11-21 19:50:40 +03:00
ifv
cc164fd7dc 0033170: Modeling Algorithms - Checking for canonical geometry: plane detection problems
GeomLib_IsPlanarSurface.cxx - using poles for checking BSpline, Bezier curves and surface changed
                              on checking by curve, surface points.

BRepOffset_MakeOffset.cxx - set normal of plane surface according to normal of initial face surface

tests/cr/bugs/bug33170 - new test case added
2022-11-21 19:44:10 +03:00
ona
d7d89acb39 0032977: OCC V7.5, V7.6 cannot read STEP color correctly for the root label, but v6.8 can
- color overriding mechanism is implemented for assembles, parts and instances
2022-11-21 19:41:08 +03:00
Eugeny Maltchikov
d444cc35c6 0033171: Modeling Algorithms - Invalid result of faces unification
Avoid unification of the faces belonging to the different shells.
2022-11-21 19:38:22 +03:00
smoskvin
eeba62cbd3 Increment OCCT version up to 7.8.0dev 2022-11-12 01:20:10 +03:00
14 changed files with 221 additions and 825 deletions

View File

@@ -725,7 +725,7 @@ Another possible problem is the order of initialization of global variables defi
Avoid explicit usage of basic types (*int*, *float*, *double*, etc.), use Open CASCADE Technology types from package *Standard: Standard_Integer, Standard_Real, Standard_ShortReal, Standard_Boolean, Standard_CString* and others or a specific *typedef* instead.
### Use sizeof() to calculate sizes [MANDATORY]
### Use *sizeof()* to calculate sizes [MANDATORY]
Do not assume sizes of types. Use *sizeof()* instead to calculate sizes.
@@ -738,7 +738,7 @@ It is recommended to follow this rule for any plain text files for consistency a
The rules listed in this chapter are important for stability of the programs that use Open CASCADE Technology libraries.
### Use OSD::SetSignal() to catch exceptions
### Use *OSD::SetSignal()* to catch exceptions
When using Open CASCADE Technology in an application, call *OSD::SetSignal()* function when the application is initialized.
@@ -787,7 +787,7 @@ See the following example:
In C++ use *new* and *delete* operators instead of *malloc()* and *free()*. Try not to mix different memory allocation techniques.
### Match new and delete [MANDATORY]
### Match *new* and *delete* [MANDATORY]
Use the same form of new and delete.
@@ -812,7 +812,7 @@ Standard_Integer aTmpVar2 = 0; // OK
Uninitialized variables might be kept only within performance-sensitive code blocks and only when their initialization is guaranteed by subsequent code.
### Do not hide global new
### Do not hide global *new*
Avoid hiding the global *new* operator.

View File

@@ -780,7 +780,7 @@ restore theBox
@subsubsection occt_draw_3_3_1 set
#### In DrawTrSurf package:
#### In *DrawTrSurf* package:
~~~~{.php}
void Set(Standard_CString& Name,const gp_Pnt& G) ;
@@ -797,7 +797,7 @@ void Set(Standard_CString& Name,
const Handle(Poly_Polygon2D)& P) ;
~~~~
#### In DBRep package:
#### In *DBRep* package:
~~~~{.php}
void Set(const Standard_CString Name,
@@ -822,13 +822,13 @@ DBRep::Set(char*,B);
@subsubsection occt_draw_3_3_2 get
#### In DrawTrSurf package:
#### In *DrawTrSurf* package:
~~~~{.php}
Handle_Geom_Geometry Get(Standard_CString& Name) ;
~~~~
#### In DBRep package:
#### In *DBRep* package:
~~~~{.php}
TopoDS_Shape Get(Standard_CString& Name,

View File

@@ -86,9 +86,7 @@ int ec_error ( const std::string& s, const std::string& text )
%top{
// Pre-include stdlib.h to avoid redefinition of integer type macros (INT8_MIN and similar in generated code)
#if !defined(_MSC_VER) || (_MSC_VER >= 1600) // Visual Studio 2010+
#include "stdint.h"
#endif
#include <Standard_TypeDef.hxx>
}
%{

View File

@@ -1,7 +1,5 @@
// Pre-include stdlib.h to avoid redefinition of integer type macros (INT8_MIN and similar in generated code)
#if !defined(_MSC_VER) || (_MSC_VER >= 1600) // Visual Studio 2010+
#include "stdint.h"
#endif
#include <Standard_TypeDef.hxx>
#define YY_INT_ALIGNED short int

View File

@@ -135,10 +135,6 @@ namespace
Image_FreeImageStream (std::istream& theStream)
: myIStream (&theStream), myOStream (NULL), myInitPos (theStream.tellg()) {}
//! Construct wrapper over output stream.
Image_FreeImageStream (std::ostream& theStream)
: myIStream (NULL), myOStream (&theStream), myInitPos (theStream.tellp()) {}
//! Get io object.
FreeImageIO GetFiIO() const
{
@@ -147,15 +143,12 @@ namespace
if (myIStream != NULL)
{
anIo.read_proc = readProc;
anIo.seek_proc = seekProcIn;
anIo.tell_proc = tellProcIn;
anIo.seek_proc = seekProc;
anIo.tell_proc = tellProc;
}
if (myOStream != NULL)
{
anIo.write_proc = writeProc;
// seek and tell are also used for saving in some formats (.tif for example)
anIo.seek_proc = seekProcOut;
anIo.tell_proc = tellProcOut;
}
return anIo;
}
@@ -190,7 +183,7 @@ namespace
}
//! Simulate fseek().
static int DLL_CALLCONV seekProcIn (fi_handle theHandle, long theOffset, int theOrigin)
static int DLL_CALLCONV seekProc (fi_handle theHandle, long theOffset, int theOrigin)
{
Image_FreeImageStream* aThis = (Image_FreeImageStream* )theHandle;
if (aThis->myIStream == NULL)
@@ -223,53 +216,13 @@ namespace
return isSeekDone ? 0 : -1;
}
static int DLL_CALLCONV seekProcOut (fi_handle theHandle, long theOffset, int theOrigin)
{
Image_FreeImageStream* aThis = (Image_FreeImageStream* )theHandle;
if (aThis->myOStream == NULL)
{
return -1;
}
bool isSeekDone = false;
switch (theOrigin)
{
case SEEK_SET:
if (aThis->myOStream->seekp ((std::streamoff )aThis->myInitPos + theOffset, std::ios::beg))
{
isSeekDone = true;
}
break;
case SEEK_CUR:
if (aThis->myOStream->seekp (theOffset, std::ios::cur))
{
isSeekDone = true;
}
break;
case SEEK_END:
if (aThis->myOStream->seekp (theOffset, std::ios::end))
{
isSeekDone = true;
}
break;
}
return isSeekDone ? 0 : -1;
}
//! Simulate ftell().
static long DLL_CALLCONV tellProcIn (fi_handle theHandle)
static long DLL_CALLCONV tellProc (fi_handle theHandle)
{
Image_FreeImageStream* aThis = (Image_FreeImageStream* )theHandle;
const long aPos = aThis->myIStream != NULL ? (long )(aThis->myIStream->tellg() - aThis->myInitPos) : 0;
return aPos;
}
static long DLL_CALLCONV tellProcOut (fi_handle theHandle)
{
Image_FreeImageStream* aThis = (Image_FreeImageStream* )theHandle;
const long aPos = aThis->myOStream != NULL ? (long )(aThis->myOStream->tellp() - aThis->myInitPos) : 0;
return aPos;
}
private:
std::istream* myIStream;
std::ostream* myOStream;
@@ -285,37 +238,6 @@ namespace
return aGuid;
}
//! Returns GUID of image format from file name
static GUID getFileFormatFromName (const TCollection_AsciiString& theFileName)
{
TCollection_AsciiString aFileNameLower = theFileName;
aFileNameLower.LowerCase();
GUID aFileFormat = getNullGuid();
if (aFileNameLower.EndsWith (".bmp"))
{
aFileFormat = GUID_ContainerFormatBmp;
}
else if (aFileNameLower.EndsWith (".png"))
{
aFileFormat = GUID_ContainerFormatPng;
}
else if (aFileNameLower.EndsWith (".jpg")
|| aFileNameLower.EndsWith (".jpeg"))
{
aFileFormat = GUID_ContainerFormatJpeg;
}
else if (aFileNameLower.EndsWith (".tiff")
|| aFileNameLower.EndsWith (".tif"))
{
aFileFormat = GUID_ContainerFormatTiff;
}
else if (aFileNameLower.EndsWith (".gif"))
{
aFileFormat = GUID_ContainerFormatGif;
}
return aFileFormat;
}
//! Sentry over IUnknown pointer.
template<class T> class Image_ComPtr
{
@@ -424,11 +346,7 @@ namespace
// purpose :
// =======================================================================
Image_AlienPixMap::Image_AlienPixMap()
#ifdef HAVE_WINCODEC
: myPalette (NULL)
#else
: myLibImage (NULL)
#endif
{
SetTopDown (false);
}
@@ -587,12 +505,6 @@ void Image_AlienPixMap::Clear()
FreeImage_Unload (myLibImage);
myLibImage = NULL;
}
#elif defined(HAVE_WINCODEC)
if (myPalette != NULL)
{
myPalette->Release();
myPalette = NULL;
}
#elif defined(__EMSCRIPTEN__)
if (myLibImage != NULL)
{
@@ -623,7 +535,7 @@ bool Image_AlienPixMap::IsTopDownDefault()
// =======================================================================
#ifdef HAVE_FREEIMAGE
bool Image_AlienPixMap::Load (const Standard_Byte* theData,
const Standard_Size theLength,
Standard_Size theLength,
const TCollection_AsciiString& theImagePath)
{
Clear();
@@ -793,7 +705,7 @@ bool Image_AlienPixMap::Load (std::istream& theStream,
#elif defined(HAVE_WINCODEC)
bool Image_AlienPixMap::Load (const Standard_Byte* theData,
const Standard_Size theLength,
Standard_Size theLength,
const TCollection_AsciiString& theFileName)
{
Clear();
@@ -839,7 +751,7 @@ bool Image_AlienPixMap::Load (const Standard_Byte* theData,
|| aFrameCount < 1
|| aWicDecoder->GetFrame (0, &aWicFrameDecode.ChangePtr()) != S_OK
|| aWicFrameDecode->GetSize (&aFrameSizeX, &aFrameSizeY) != S_OK
|| aWicFrameDecode->GetPixelFormat (&aWicPixelFormat) != S_OK)
|| aWicFrameDecode->GetPixelFormat (&aWicPixelFormat))
{
Message::SendFail ("Error: cannot get WIC Image Frame");
return false;
@@ -856,6 +768,7 @@ bool Image_AlienPixMap::Load (const Standard_Byte* theData,
Message::SendFail ("Error: cannot convert WIC Image Frame to RGB format");
return false;
}
aWicFrameDecode.Nullify();
}
if (!Image_PixMap::InitTrash (aPixelFormat, aFrameSizeX, aFrameSizeY))
@@ -864,37 +777,17 @@ bool Image_AlienPixMap::Load (const Standard_Byte* theData,
return false;
}
TCollection_AsciiString aFileNameLower = theFileName;
aFileNameLower.LowerCase();
if (aFileNameLower.EndsWith (".gif")
&& (aWicImgFactory->CreatePalette (&myPalette) != S_OK
|| aWicFrameDecode->CopyPalette (myPalette) != S_OK))
{
Message::SendFail ("Error: cannot get palette for GIF image");
return false;
}
IWICBitmapSource* aWicSrc = aWicFrameDecode.get();
if(!aWicConvertedFrame.IsNull())
{
aWicSrc = aWicConvertedFrame.get();
}
IWICBitmapFlipRotator* aRotator;
bool isTopDown = true;
if (aWicImgFactory->CreateBitmapFlipRotator (&aRotator) == S_OK
&& aRotator->Initialize (aWicSrc, WICBitmapTransformFlipVertical) == S_OK)
{
isTopDown = false;
aWicSrc = aRotator;
}
if (aWicSrc->CopyPixels (NULL, (UINT )SizeRowBytes(), (UINT )SizeBytes(), ChangeData()) != S_OK)
{
Message::SendFail ("Error: cannot copy pixels from WIC Image");
return false;
}
SetTopDown (isTopDown);
SetTopDown (true);
return true;
}
bool Image_AlienPixMap::Load (std::istream& theStream,
@@ -931,7 +824,7 @@ bool Image_AlienPixMap::Load (std::istream& ,
return false;
}
bool Image_AlienPixMap::Load (const Standard_Byte* theData,
const Standard_Size theLength,
Standard_Size theLength,
const TCollection_AsciiString& theImagePath)
{
Clear();
@@ -964,7 +857,7 @@ bool Image_AlienPixMap::Load (std::istream& ,
return false;
}
bool Image_AlienPixMap::Load (const Standard_Byte* ,
const Standard_Size ,
Standard_Size ,
const TCollection_AsciiString& )
{
Clear();
@@ -1014,52 +907,11 @@ bool Image_AlienPixMap::savePPM (const TCollection_AsciiString& theFileName) con
return true;
}
// =======================================================================
// function : convertData
// purpose :
// =======================================================================
#ifdef HAVE_WINCODEC
static bool convertData (const Image_AlienPixMap& theSrcPixMapData,
const WICPixelFormatGUID& theFormat,
IWICImagingFactory& theWicImgFactory,
Image_PixMapData& theDstPixMapData)
{
const UINT aSizeRowBytes = (UINT)theSrcPixMapData.SizeRowBytes();
const UINT aSizeBytes = (UINT)theSrcPixMapData.SizeBytes();
Image_ComPtr<IWICBitmap> anSrcImg;
Image_ComPtr<IWICFormatConverter> aWicFormatConverter;
HRESULT anHResult = theWicImgFactory.CreateBitmapFromMemory ((UINT)theSrcPixMapData.SizeX(), (UINT)theSrcPixMapData.SizeY(),
convertToWicFormat (theSrcPixMapData.Format()),
aSizeRowBytes, aSizeBytes,
(BYTE*)theSrcPixMapData.Data(), &anSrcImg.ChangePtr());
if (anHResult != S_OK
|| theWicImgFactory.CreateFormatConverter (&aWicFormatConverter.ChangePtr()) != S_OK
|| aWicFormatConverter->Initialize (anSrcImg.get(), theFormat, WICBitmapDitherTypeNone, theSrcPixMapData.GetPalette(), 0.0f, WICBitmapPaletteTypeCustom) != S_OK)
{
Message::SendFail ("Error: cannot convert WIC Image Frame to required format");
return false;
}
theDstPixMapData.Init (Image_PixMap::DefaultAllocator(), 1, theSrcPixMapData.SizeXYZ(), aSizeRowBytes, NULL);
if (aWicFormatConverter->CopyPixels (NULL, aSizeRowBytes, aSizeBytes, theDstPixMapData.ChangeData()) != S_OK)
{
Message::SendFail ("Error: cannot copy pixels from WIC Image");
return false;
}
return true;
}
#endif
// =======================================================================
// function : Save
// purpose :
// =======================================================================
bool Image_AlienPixMap::Save (Standard_Byte* theBuffer,
const Standard_Size theLength,
const TCollection_AsciiString& theFileName)
bool Image_AlienPixMap::Save (const TCollection_AsciiString& theFileName)
{
#ifdef HAVE_FREEIMAGE
if (myLibImage == NULL)
@@ -1087,399 +939,10 @@ bool Image_AlienPixMap::Save (Standard_Byte* theBuffer,
SetTopDown (false);
}
FIBITMAP* anImageToDump = getImageToDump (anImageFormat);
if (anImageToDump == NULL)
{
return false;
}
bool isSaved = false;
if (theBuffer != NULL)
{
// a memory buffer wrapped by FreeImage is read only (images can be loaded but not be saved)
// so we call FreeImage_OpenMemory() with default arguments and just memcpy in requsted buffer.
FIMEMORY* aFiMem = FreeImage_OpenMemory();
isSaved = (FreeImage_SaveToMemory (anImageFormat, anImageToDump, aFiMem) != FALSE);
BYTE* aData = NULL;
DWORD aSize;
FreeImage_AcquireMemory (aFiMem, &aData, &aSize);
if (aSize > theLength)
{
Message::SendFail ("Error: memory buffer too small for storing image");
return false;
}
memcpy (theBuffer, aData, aSize);
FreeImage_CloseMemory (aFiMem);
}
else
{
#ifdef _WIN32
isSaved = (FreeImage_SaveU (anImageFormat, anImageToDump, aFileNameW.ToWideString ()) != FALSE);
#else
isSaved = (FreeImage_Save (anImageFormat, anImageToDump, theFileName.ToCString ()) != FALSE);
#endif
}
if (anImageToDump != myLibImage)
{
FreeImage_Unload (anImageToDump);
}
return isSaved;
#elif defined(HAVE_WINCODEC)
TCollection_AsciiString aFileNameLower = theFileName;
aFileNameLower.LowerCase();
if (aFileNameLower.EndsWith (".ppm"))
{
return savePPM (theFileName);
}
GUID aFileFormat = getFileFormatFromName (theFileName);
if (aFileFormat == getNullGuid())
{
Message::SendFail ("Error: unsupported image format");
return false;
}
Image_ComPtr<IWICImagingFactory> aWicImgFactory;
CoInitializeEx (NULL, COINIT_MULTITHREADED);
if (CoCreateInstance (CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&aWicImgFactory.ChangePtr())) != S_OK)
{
Message::SendFail ("Error: cannot initialize WIC Imaging Factory");
return false;
}
WICPixelFormatGUID aWicPixelFormat = convertToWicFormat (myImgFormat);
if (aWicPixelFormat == getNullGuid())
{
Message::SendFail ("Error: unsupported pixel format");
return false;
}
Image_PixMapData* aPixMapData = &myData;
Image_PixMapData aConvertedData;
if (aFileFormat == GUID_ContainerFormatGif)
{
aWicPixelFormat = GUID_WICPixelFormat8bppIndexed;
convertData (*this, aWicPixelFormat, *aWicImgFactory, aConvertedData);
aPixMapData = &aConvertedData;
}
Image_ComPtr<IWICStream> aWicStream;
Image_ComPtr<IWICBitmapEncoder> aWicEncoder;
const TCollection_ExtendedString aFileNameW (theFileName);
if (theBuffer != NULL)
{
if (aWicImgFactory->CreateStream (&aWicStream.ChangePtr()) != S_OK
|| aWicStream->InitializeFromMemory (theBuffer,(DWORD )theLength) != S_OK)
{
Message::SendFail ("Error: cannot create WIC Memory Stream");
return false;
}
}
else
{
if (aWicImgFactory->CreateStream (&aWicStream.ChangePtr()) != S_OK
|| aWicStream->InitializeFromFilename (aFileNameW.ToWideString(), GENERIC_WRITE) != S_OK)
{
Message::SendFail ("Error: cannot create WIC File Stream");
return false;
}
}
if (aWicImgFactory->CreateEncoder (aFileFormat, NULL, &aWicEncoder.ChangePtr()) != S_OK
|| aWicEncoder->Initialize (aWicStream.get(), WICBitmapEncoderNoCache) != S_OK)
{
Message::SendFail ("Error: cannot create WIC Encoder");
return false;
}
WICPixelFormatGUID aWicPixelFormatRes = aWicPixelFormat;
Image_ComPtr<IWICBitmapFrameEncode> aWicFrameEncode;
if (aWicEncoder->CreateNewFrame (&aWicFrameEncode.ChangePtr(), NULL) != S_OK
|| aWicFrameEncode->Initialize (NULL) != S_OK
|| aWicFrameEncode->SetSize ((UINT )SizeX(), (UINT )SizeY()) != S_OK
|| aWicFrameEncode->SetPixelFormat (&aWicPixelFormatRes) != S_OK)
{
Message::SendFail ("Error: cannot create WIC Frame");
return false;
}
if (aFileFormat == GUID_ContainerFormatGif
&& (myPalette == NULL
|| aWicFrameEncode->SetPalette (myPalette) != S_OK))
{
Message::SendFail ("Error: cannot set palette");
return false;
}
if (aWicPixelFormatRes != aWicPixelFormat)
{
Message::SendFail ("Error: pixel format is unsupported by image format");
return false;
}
if (IsTopDown())
{
if (aWicFrameEncode->WritePixels ((UINT )SizeY(), (UINT )SizeRowBytes(), (UINT )SizeBytes(), (BYTE* )aPixMapData->Data()) != S_OK)
{
Message::SendFail ("Error: cannot write pixels to WIC Frame");
return false;
}
}
else
{
for (Standard_Size aRow = 0; aRow < SizeY(); ++aRow)
{
if (aWicFrameEncode->WritePixels (1, (UINT )SizeRowBytes(), (UINT )SizeRowBytes(), (BYTE* )aPixMapData->Row (aRow)) != S_OK)
{
Message::SendFail ("Error: cannot write pixels to WIC Frame");
return false;
}
}
}
if (aWicFrameEncode->Commit() != S_OK
|| aWicEncoder->Commit() != S_OK)
{
Message::SendFail ("Error: cannot commit data to WIC Frame");
return false;
}
if (aWicStream->Commit (STGC_DEFAULT) != S_OK)
{
//Message::Send ("Error: cannot commit data to WIC File Stream", Message_Fail);
//return false;
}
return true;
#else
if (theBuffer != NULL)
{
Message::SendFail ("Error: no image library available");
return false;
}
const Standard_Integer aLen = theFileName.Length();
if ((aLen >= 4) && (theFileName.Value (aLen - 3) == '.')
&& strcasecmp( theFileName.ToCString() + aLen - 3, "ppm") == 0 )
{
return savePPM (theFileName);
}
Message::SendTrace ("Image_PixMap, no image library available! Image saved in PPM format");
return savePPM (theFileName);
#endif
}
bool Image_AlienPixMap::Save (std::ostream& theStream, const TCollection_AsciiString& theExtension)
{
#ifdef HAVE_FREEIMAGE
if (myLibImage == NULL)
{
return false;
}
#ifdef _WIN32
const TCollection_ExtendedString anExtW (theExtension.ToCString(), Standard_True);
FREE_IMAGE_FORMAT anImageFormat = FreeImage_GetFIFFromFilenameU (anExtW.ToWideString());
#else
FREE_IMAGE_FORMAT anImageFormat = FreeImage_GetFIFFromFilename (theExtension.ToCString());
#endif
if (anImageFormat == FIF_UNKNOWN)
{
#ifdef OCCT_DEBUG
std::cerr << "Image_PixMap, image format doesn't supported!\n";
#endif
return false;
}
if (IsTopDown())
{
FreeImage_FlipVertical (myLibImage);
SetTopDown (false);
}
FIBITMAP* anImageToDump = getImageToDump (anImageFormat);
if (anImageToDump == NULL)
{
return false;
}
bool isSaved = false;
Image_FreeImageStream aStream (theStream);
FreeImageIO anIO = aStream.GetFiIO();
isSaved = (FreeImage_SaveToHandle(anImageFormat, anImageToDump, &anIO, &aStream) != FALSE);
if (anImageToDump != myLibImage)
{
FreeImage_Unload (anImageToDump);
}
return isSaved;
#elif defined(HAVE_WINCODEC)
GUID aFileFormat = getFileFormatFromName (theExtension);
if (aFileFormat == getNullGuid())
{
Message::SendFail ("Error: unsupported image format");
return false;
}
Image_ComPtr<IWICImagingFactory> aWicImgFactory;
CoInitializeEx (NULL, COINIT_MULTITHREADED);
if (CoCreateInstance (CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&aWicImgFactory.ChangePtr())) != S_OK)
{
Message::SendFail ("Error: cannot initialize WIC Imaging Factory");
return false;
}
WICPixelFormatGUID aWicPixelFormat = convertToWicFormat (myImgFormat);
if (aWicPixelFormat == getNullGuid())
{
Message::SendFail ("Error: unsupported pixel format");
return false;
}
Image_PixMapData* aPixMapData = &myData;
Image_PixMapData aConvertedData;
if (aFileFormat == GUID_ContainerFormatGif)
{
aWicPixelFormat = GUID_WICPixelFormat8bppIndexed;
convertData (*this, aWicPixelFormat, *aWicImgFactory, aConvertedData);
aPixMapData = &aConvertedData;
}
Image_ComPtr<IStream> aStream;
Image_ComPtr<IWICBitmapEncoder> aWicEncoder;
if (CreateStreamOnHGlobal (NULL, Standard_True, &aStream.ChangePtr()) != S_OK)
{
Message::SendFail ("Error: cannot create Stream on global");
return false;
}
if (aWicImgFactory->CreateEncoder (aFileFormat, NULL, &aWicEncoder.ChangePtr()) != S_OK
|| aWicEncoder->Initialize (aStream.get(), WICBitmapEncoderNoCache) != S_OK)
{
Message::SendFail ("Error: cannot create WIC Encoder");
return false;
}
WICPixelFormatGUID aWicPixelFormatRes = aWicPixelFormat;
Image_ComPtr<IWICBitmapFrameEncode> aWicFrameEncode;
if (aWicEncoder->CreateNewFrame (&aWicFrameEncode.ChangePtr(), NULL) != S_OK
|| aWicFrameEncode->Initialize (NULL) != S_OK
|| aWicFrameEncode->SetSize ((UINT )SizeX(), (UINT )SizeY()) != S_OK
|| aWicFrameEncode->SetPixelFormat (&aWicPixelFormatRes) != S_OK)
{
Message::SendFail ("Error: cannot create WIC Frame");
return false;
}
if (aFileFormat == GUID_ContainerFormatGif
&& (myPalette == NULL
|| aWicFrameEncode->SetPalette (myPalette) != S_OK))
{
Message::SendFail ("Error: cannot set palette");
return false;
}
if (aWicPixelFormatRes != aWicPixelFormat)
{
Message::SendFail ("Error: pixel format is unsupported by image format");
return false;
}
if (IsTopDown())
{
if (aWicFrameEncode->WritePixels ((UINT )SizeY(), (UINT )SizeRowBytes(), (UINT )SizeBytes(), (BYTE* )aPixMapData->Data()) != S_OK)
{
Message::SendFail ("Error: cannot write pixels to WIC Frame");
return false;
}
}
else
{
for (Standard_Size aRow = 0; aRow < SizeY(); ++aRow)
{
if (aWicFrameEncode->WritePixels (1, (UINT )SizeRowBytes(), (UINT )SizeRowBytes(), (BYTE* )aPixMapData->Row (aRow)) != S_OK)
{
Message::SendFail ("Error: cannot write pixels to WIC Frame");
return false;
}
}
}
if (aWicFrameEncode->Commit() != S_OK
|| aWicEncoder->Commit() != S_OK)
{
Message::SendFail ("Error: cannot commit data to WIC Frame");
return false;
}
if (aStream->Commit (STGC_DEFAULT) != S_OK)
{
//Message::Send ("Error: cannot commit data to Stream", Message_Fail);
//return false;
}
// WIC doesn't have the way to encode image directly in std::ostream
// so we use a workaround to transfer data from IStream to std::ostream
STATSTG aStat;
if (aStream->Stat (&aStat, STATFLAG_NONAME) != S_OK)
{
Message::SendFail ("Error: cannot get stat from stream");
return false;
}
HGLOBAL aMem;
if (GetHGlobalFromStream (aStream.get(), &aMem) != S_OK)
{
Message::SendFail ("Error: cannot get global from stream");
return false;
}
LPVOID aData = GlobalLock (aMem);
if (aData == NULL)
{
Message::SendFail ("Error: cannot lock global");
return false;
}
if (!theStream.write ((const char* )aData, aStat.cbSize.QuadPart))
{
Message::SendFail ("Error: cannot write data to ostream");
return false;
}
if (GlobalUnlock (aMem) == 0 && GetLastError() != NO_ERROR)
{
Message::SendFail ("Error: cannot unlock global");
return false;
}
return true;
#else
Message::SendFail ("Error: no image library available");
return false;
#endif
}
// =======================================================================
// function : AdjustGamma
// purpose :
// =======================================================================
bool Image_AlienPixMap::AdjustGamma (const Standard_Real theGammaCorr)
{
#ifdef HAVE_FREEIMAGE
return FreeImage_AdjustGamma (myLibImage, theGammaCorr) != FALSE;
#else
(void )theGammaCorr;
return false;
#endif
}
#ifdef HAVE_FREEIMAGE
// =======================================================================
// function : GetImageToDump
// purpose :
// =======================================================================
FIBITMAP* Image_AlienPixMap::getImageToDump (const Standard_Integer theFormat)
{
FIBITMAP* anImageToDump = myLibImage;
// FreeImage doesn't provide flexible format conversion API
// so we should perform multiple conversions in some cases!
switch (theFormat)
FIBITMAP* anImageToDump = myLibImage;
switch (anImageFormat)
{
case FIF_PNG:
case FIF_BMP:
@@ -1510,7 +973,7 @@ FIBITMAP* Image_AlienPixMap::getImageToDump (const Standard_Integer theFormat)
aTmpBitmap = FreeImage_ConvertToType (myLibImage, FIT_BITMAP);
if (aTmpBitmap == NULL)
{
return NULL;
return false;
}
}
@@ -1523,7 +986,7 @@ FIBITMAP* Image_AlienPixMap::getImageToDump (const Standard_Integer theFormat)
}
if (aTmpBitmap24 == NULL)
{
return NULL;
return false;
}
aTmpBitmap = aTmpBitmap24;
}
@@ -1568,7 +1031,7 @@ FIBITMAP* Image_AlienPixMap::getImageToDump (const Standard_Integer theFormat)
anImageToDump = FreeImage_ConvertToType (myLibImage, FIT_BITMAP);
if (anImageToDump == NULL)
{
return NULL;
return false;
}
}
@@ -1581,13 +1044,170 @@ FIBITMAP* Image_AlienPixMap::getImageToDump (const Standard_Integer theFormat)
}
if (aTmpBitmap24 == NULL)
{
return NULL;
return false;
}
anImageToDump = aTmpBitmap24;
}
break;
}
}
return anImageToDump;
}
if (anImageToDump == NULL)
{
return false;
}
#ifdef _WIN32
bool isSaved = (FreeImage_SaveU (anImageFormat, anImageToDump, aFileNameW.ToWideString()) != FALSE);
#else
bool isSaved = (FreeImage_Save (anImageFormat, anImageToDump, theFileName.ToCString()) != FALSE);
#endif
if (anImageToDump != myLibImage)
{
FreeImage_Unload (anImageToDump);
}
return isSaved;
#elif defined(HAVE_WINCODEC)
TCollection_AsciiString aFileNameLower = theFileName;
aFileNameLower.LowerCase();
GUID aFileFormat = getNullGuid();
if (aFileNameLower.EndsWith (".ppm"))
{
return savePPM (theFileName);
}
else if (aFileNameLower.EndsWith (".bmp"))
{
aFileFormat = GUID_ContainerFormatBmp;
}
else if (aFileNameLower.EndsWith (".png"))
{
aFileFormat = GUID_ContainerFormatPng;
}
else if (aFileNameLower.EndsWith (".jpg")
|| aFileNameLower.EndsWith (".jpeg"))
{
aFileFormat = GUID_ContainerFormatJpeg;
}
else if (aFileNameLower.EndsWith (".tiff")
|| aFileNameLower.EndsWith (".tif"))
{
aFileFormat = GUID_ContainerFormatTiff;
}
else if (aFileNameLower.EndsWith (".gif"))
{
aFileFormat = GUID_ContainerFormatGif;
}
if (aFileFormat == getNullGuid())
{
Message::SendFail ("Error: unsupported image format");
return false;
}
Image_ComPtr<IWICImagingFactory> aWicImgFactory;
CoInitializeEx (NULL, COINIT_MULTITHREADED);
if (CoCreateInstance (CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&aWicImgFactory.ChangePtr())) != S_OK)
{
Message::SendFail ("Error: cannot initialize WIC Imaging Factory");
return false;
}
Image_ComPtr<IWICStream> aWicFileStream;
Image_ComPtr<IWICBitmapEncoder> aWicEncoder;
const TCollection_ExtendedString aFileNameW (theFileName);
if (aWicImgFactory->CreateStream (&aWicFileStream.ChangePtr()) != S_OK
|| aWicFileStream->InitializeFromFilename (aFileNameW.ToWideString(), GENERIC_WRITE) != S_OK)
{
Message::SendFail ("Error: cannot create WIC File Stream");
return false;
}
if (aWicImgFactory->CreateEncoder (aFileFormat, NULL, &aWicEncoder.ChangePtr()) != S_OK
|| aWicEncoder->Initialize (aWicFileStream.get(), WICBitmapEncoderNoCache) != S_OK)
{
Message::SendFail ("Error: cannot create WIC Encoder");
return false;
}
const WICPixelFormatGUID aWicPixelFormat = convertToWicFormat (myImgFormat);
if (aWicPixelFormat == getNullGuid())
{
Message::SendFail ("Error: unsupported pixel format");
return false;
}
WICPixelFormatGUID aWicPixelFormatRes = aWicPixelFormat;
Image_ComPtr<IWICBitmapFrameEncode> aWicFrameEncode;
if (aWicEncoder->CreateNewFrame (&aWicFrameEncode.ChangePtr(), NULL) != S_OK
|| aWicFrameEncode->Initialize (NULL) != S_OK
|| aWicFrameEncode->SetSize ((UINT )SizeX(), (UINT )SizeY()) != S_OK
|| aWicFrameEncode->SetPixelFormat (&aWicPixelFormatRes) != S_OK)
{
Message::SendFail ("Error: cannot create WIC Frame");
return false;
}
if (aWicPixelFormatRes != aWicPixelFormat)
{
Message::SendFail ("Error: pixel format is unsupported by image format");
return false;
}
if (IsTopDown())
{
if (aWicFrameEncode->WritePixels ((UINT )SizeY(), (UINT )SizeRowBytes(), (UINT )SizeBytes(), (BYTE* )Data()) != S_OK)
{
Message::SendFail ("Error: cannot write pixels to WIC Frame");
return false;
}
}
else
{
for (Standard_Size aRow = 0; aRow < SizeY(); ++aRow)
{
if (aWicFrameEncode->WritePixels (1, (UINT )SizeRowBytes(), (UINT )SizeRowBytes(), (BYTE* )Row (aRow)) != S_OK)
{
Message::SendFail ("Error: cannot write pixels to WIC Frame");
return false;
}
}
}
if (aWicFrameEncode->Commit() != S_OK
|| aWicEncoder->Commit() != S_OK)
{
Message::SendFail ("Error: cannot commit data to WIC Frame");
return false;
}
if (aWicFileStream->Commit (STGC_DEFAULT) != S_OK)
{
//Message::Send ("Error: cannot commit data to WIC File Stream", Message_Fail);
//return false;
}
return true;
#else
const Standard_Integer aLen = theFileName.Length();
if ((aLen >= 4) && (theFileName.Value (aLen - 3) == '.')
&& strcasecmp( theFileName.ToCString() + aLen - 3, "ppm") == 0 )
{
return savePPM (theFileName);
}
Message::SendTrace ("Image_PixMap, no image library available! Image saved in PPM format");
return savePPM (theFileName);
#endif
}
// =======================================================================
// function : AdjustGamma
// purpose :
// =======================================================================
bool Image_AlienPixMap::AdjustGamma (const Standard_Real theGammaCorr)
{
#ifdef HAVE_FREEIMAGE
return FreeImage_AdjustGamma (myLibImage, theGammaCorr) != FALSE;
#else
(void )theGammaCorr;
return false;
#endif
}

View File

@@ -19,7 +19,6 @@
#include <Image_PixMap.hxx>
class TCollection_AsciiString;
struct IWICPalette;
struct FIBITMAP;
//! Image class that support file reading/writing operations using auxiliary image library.
@@ -58,41 +57,21 @@ public:
const TCollection_AsciiString& theFileName);
//! Read image data from memory buffer.
//! @param[in] theData memory pointer to read from;
//! when NULL, function will attempt to open theFileName file
//! @param[in] theLength memory buffer length
//! @param[in] theFileName optional file name
//! @param theData memory pointer to read from;
//! when NULL, function will attempt to open theFileName file
//! @param theLength memory buffer length
//! @param theFileName optional file name
Standard_EXPORT bool Load (const Standard_Byte* theData,
const Standard_Size theLength,
Standard_Size theLength,
const TCollection_AsciiString& theFileName);
//! Write image data to file.
//! @param[in] theFileName file name to save
bool Save (const TCollection_AsciiString& theFileName)
{
return Save (NULL, 0, theFileName);
}
//! Write image data to stream.
//! @param[out] theStream stream where to write
//! @param[in] theExtension image format
Standard_EXPORT bool Save (std::ostream& theStream,
const TCollection_AsciiString& theExtension);
//! Write image data to file or memory buffer using file extension to determine format.
//! @param[out] theBuffer buffer pointer where to write
//! when NULL, function write image data to theFileName file
//! @param[in] theLength memory buffer length
//! @param[in] theFileName file name to save;
//! when theBuffer isn't NULL used only to determine format
Standard_EXPORT bool Save (Standard_Byte* theBuffer,
const Standard_Size theLength,
const TCollection_AsciiString& theFileName);
//! Write image data to file using file extension to determine compression format.
Standard_EXPORT bool Save (const TCollection_AsciiString& theFileName);
//! Initialize image plane with required dimensions.
//! @param[in] thePixelFormat if specified pixel format doesn't supported by image library
//! than nearest supported will be used instead!
//! @param[in] theSizeRowBytes may be ignored by this class and required alignment will be used instead!
//! thePixelFormat - if specified pixel format doesn't supported by image library
//! than nearest supported will be used instead!
//! theSizeRowBytes - may be ignored by this class and required alignment will be used instead!
Standard_EXPORT virtual bool InitTrash (Image_Format thePixelFormat,
const Standard_Size theSizeX,
const Standard_Size theSizeY,
@@ -105,13 +84,12 @@ public:
Standard_EXPORT virtual void Clear() Standard_OVERRIDE;
//! Performs gamma correction on image.
//! @param[in] theGamma - gamma value to use; a value of 1.0 leaves the image alone
//! theGamma - gamma value to use; a value of 1.0 leaves the image alone
Standard_EXPORT bool AdjustGamma (const Standard_Real theGammaCorr);
#if !defined(HAVE_FREEIMAGE) && defined(_WIN32)
//! Returns image palette.
IWICPalette* GetPalette() const { return myPalette; }
#endif
private:
FIBITMAP* myLibImage;
private:
@@ -130,13 +108,6 @@ private:
//! Built-in PPM export
Standard_EXPORT bool savePPM (const TCollection_AsciiString& theFileName) const;
FIBITMAP* getImageToDump (const Standard_Integer theFormat);
private:
FIBITMAP* myLibImage;
IWICPalette* myPalette;
};
DEFINE_STANDARD_HANDLE(Image_AlienPixMap, Image_PixMap)

View File

@@ -224,7 +224,7 @@ const gp_Pnt &IntTools_SurfaceRangeLocalizeData::GetPointInFrame
Standard_Integer aFrmUInd = theUIndex + myUIndMin - 1;
Standard_Integer aFrmVInd = theVIndex + myVIndMin - 1;
if (myGridPoints.IsNull() || aFrmUInd > myUIndMax || aFrmVInd > myVIndMax)
if (aFrmUInd > myUIndMax || aFrmVInd > myVIndMax)
return gp::Origin();
return myGridPoints->Value(aFrmUInd, aFrmVInd);
@@ -235,7 +235,7 @@ Standard_Real IntTools_SurfaceRangeLocalizeData::GetUParamInFrame
{
Standard_Integer aFrmInd = theIndex + myUIndMin - 1;
if (myUParams.IsNull() || aFrmInd > myUIndMax)
if (aFrmInd > myUIndMax)
return Precision::Infinite();
return myUParams->Value(aFrmInd);
@@ -246,7 +246,7 @@ Standard_Real IntTools_SurfaceRangeLocalizeData::GetVParamInFrame
{
Standard_Integer aFrmInd = theIndex + myVIndMin - 1;
if (myVParams.IsNull() || aFrmInd > myVIndMax)
if (aFrmInd > myVIndMax)
return Precision::Infinite();
return myVParams->Value(aFrmInd);

View File

@@ -387,11 +387,11 @@ static Standard_Integer OCC361bug (Draw_Interpretor& di, Standard_Integer nb, co
//function : OCC30182
//purpose : Testing different interfaces of Image_AlienPixMap::Load()
//=======================================================================
static Standard_Integer OCC30182 (Draw_Interpretor& di, Standard_Integer theNbArgs, const char** theArgVec)
static Standard_Integer OCC30182 (Draw_Interpretor& , Standard_Integer theNbArgs, const char** theArgVec)
{
if (ViewerTest::CurrentView().IsNull())
{
di << "Error: no active view\n";
std::cout << "Error: no active view\n";
return 1;
}
@@ -430,13 +430,13 @@ static Standard_Integer OCC30182 (Draw_Interpretor& di, Standard_Integer theNbAr
}
else
{
di << "Syntax error at '" << anArg << "'\n";
std::cout << "Syntax error at '" << anArg << "'\n";
return 1;
}
}
if (anImgPath.IsEmpty())
{
di << "Syntax error: wrong number of arguments\n";
std::cout << "Syntax error: wrong number of arguments\n";
return 1;
}
@@ -454,7 +454,7 @@ static Standard_Integer OCC30182 (Draw_Interpretor& di, Standard_Integer theNbAr
std::shared_ptr<std::istream> aFile = aFileSystem->OpenIStream (anImgPath, std::ios::in | std::ios::binary);
if (aFile.get() == NULL)
{
di << "Syntax error: image file '" << anImgPath << "' cannot be found\n";
std::cout << "Syntax error: image file '" << anImgPath << "' cannot be found\n";
return 1;
}
if (anOffset != 0)
@@ -469,13 +469,13 @@ static Standard_Integer OCC30182 (Draw_Interpretor& di, Standard_Integer theNbAr
aFile->seekg (anOffset);
if (aLen <= 0)
{
di << "Syntax error: wrong offset\n";
std::cout << "Syntax error: wrong offset\n";
return 1;
}
NCollection_Array1<Standard_Byte> aBuff (1, aLen);
if (!aFile->read ((char* )&aBuff.ChangeFirst(), aBuff.Size()))
{
di << "Error: unable to read file\n";
std::cout << "Error: unable to read file\n";
return 1;
}
if (!anImage->Load (&aBuff.ChangeFirst(), aBuff.Size(), anImgPath))
@@ -510,107 +510,6 @@ static Standard_Integer OCC30182 (Draw_Interpretor& di, Standard_Integer theNbAr
return 0;
}
//=======================================================================
//function : OCC31956
//purpose : Testing Image_AlienPixMap::Save() overload for saving into a memory buffer or stream
//=======================================================================
static Standard_Integer OCC31956 (Draw_Interpretor& di, Standard_Integer theNbArgs, const char** theArgVec)
{
if (ViewerTest::CurrentView().IsNull())
{
di << "Error: no active view\n";
return 1;
}
if (theNbArgs != 3 && theNbArgs != 5)
{
di << "Syntax error: wrong number of arguments\n";
return 1;
}
bool useStream = false;
TCollection_AsciiString aTempImgPath;
if (theNbArgs == 5)
{
TCollection_AsciiString anArg (theArgVec[3]);
anArg.LowerCase();
if (anArg == "-stream")
{
useStream = true;
aTempImgPath = theArgVec[4];
}
else
{
di << "Syntax error at '" << anArg << "'\n";
return 1;
}
}
TCollection_AsciiString aPrsName, anImgPath;
aPrsName = theArgVec[1];
anImgPath = theArgVec[2];
Handle(Image_AlienPixMap) anImage = new Image_AlienPixMap();
const Handle(OSD_FileSystem)& aFileSystem = OSD_FileSystem::DefaultFileSystem();
opencascade::std::shared_ptr<std::istream> aFile = aFileSystem->OpenIStream (anImgPath, std::ios::in | std::ios::binary);
if (aFile.get() == NULL)
{
di << "Syntax error: image file '" << anImgPath << "' cannot be found\n";
return 1;
}
aFile->seekg (0, std::ios::end);
Standard_Integer aLen = (Standard_Integer )aFile->tellg();
aFile->seekg (0);
if (!anImage->Load (*aFile, anImgPath))
{
return 0;
}
Handle(Image_AlienPixMap) aControlImg = new Image_AlienPixMap();
if (useStream)
{
opencascade::std::shared_ptr<std::ostream> aTempFile = aFileSystem->OpenOStream (aTempImgPath, std::ios::out | std::ios::binary);
if (aTempFile.get() == NULL)
{
di << "Error: image file '" << aTempImgPath << "' cannot be open\n";
return 0;
}
if (!anImage->Save (*aTempFile, aTempImgPath))
{
di << "Error: failed saving file using stream '" << aTempImgPath << "'\n";
return 0;
}
aTempFile.reset();
aControlImg->Load (aTempImgPath);
}
else
{
NCollection_Array1<Standard_Byte> aBuff (1, aLen + 2048);
if (!anImage->Save (&aBuff.ChangeFirst(), aBuff.Size(), anImgPath))
{
di << "Error: failed saving file using buffer'" << anImgPath << "'\n";
return 0;
}
aControlImg->Load (&aBuff.ChangeFirst(), aBuff.Size(), anImgPath);
}
TopoDS_Shape aShape = BRepPrimAPI_MakeBox (100.0 * aControlImg->Ratio(), 100.0, 1.0).Shape();
Handle(AIS_Shape) aPrs = new AIS_Shape (aShape);
aPrs->SetDisplayMode (AIS_Shaded);
aPrs->Attributes()->SetupOwnShadingAspect();
const Handle(Graphic3d_AspectFillArea3d)& anAspect = aPrs->Attributes()->ShadingAspect()->Aspect();
anAspect->SetShadingModel (Graphic3d_TOSM_UNLIT);
anAspect->SetTextureMapOn (true);
anAspect->SetTextureMap (new Graphic3d_Texture2D(aControlImg));
if (aControlImg->IsTopDown())
{
anAspect->TextureMap()->GetParams()->SetTranslation (Graphic3d_Vec2 (0.0f, -1.0f));
anAspect->TextureMap()->GetParams()->SetScale (Graphic3d_Vec2 (1.0f, -1.0f));
}
ViewerTest::Display (aPrsName, aPrs, true, true);
return 0;
}
void QABugs::Commands_1(Draw_Interpretor& theCommands) {
const char *group = "QABugs";
@@ -628,7 +527,5 @@ void QABugs::Commands_1(Draw_Interpretor& theCommands) {
theCommands.Add ("OCC30182",
"OCC30182 name image [-offset Start] [-fileName] [-stream] [-memory]\n"
"Decodes image either by passing file name, file stream or memory stream", __FILE__, OCC30182, group);
theCommands.Add ("OCC31956", "OCC31956 name image [-stream tempImage]\n"
"Loads image and saves it into memory buffer or stream then loads it back", __FILE__, OCC31956, group);
return;
}

View File

@@ -17,41 +17,8 @@
#include <cstddef>
#include <ctime>
#include <stdint.h>
#if(defined(_MSC_VER) && (_MSC_VER < 1800))
// only Visual Studio 2013 (vc12) provides <cinttypes> header
// we do not defined all macros here - only used by OCCT framework
#define PRIx64 "I64x"
#define PRIX64 "I64X"
#define PRId64 "I64d"
#define PRIu64 "I64u"
#define SCNd64 "I64d"
#define SCNu64 "I64u"
#ifdef _WIN64
#define PRIxPTR "I64x"
#define PRIXPTR "I64X"
#define PRIdPTR "I64d"
#define PRIuPTR "I64u"
#define SCNdPTR "I64d"
#define SCNuPTR "I64u"
#else
#define PRIxPTR "Ix"
#define PRIXPTR "IX"
#define PRIdPTR "d"
#define PRIuPTR "u"
#define SCNdPTR "d"
#define SCNuPTR "u"
#endif
#else
// should be just <cinttypes> since C++11
// however we use this code for compatibility with old C99 compilers
#ifndef __STDC_FORMAT_MACROS
#define __STDC_FORMAT_MACROS
#endif
#include <inttypes.h>
#endif
#include <cstdint>
#include <cinttypes>
#define Standard_False false
#define Standard_True true

View File

@@ -34,20 +34,20 @@
// Primary definitions
#define OCC_VERSION_MAJOR 7
#define OCC_VERSION_MINOR 7
#define OCC_VERSION_MAINTENANCE 2
#define OCC_VERSION_MINOR 8
#define OCC_VERSION_MAINTENANCE 0
//! This macro must be commented in official release, and set to non-empty
//! string in other situations, to identify specifics of the version, e.g.:
//! - "dev" for development version between releases
//! - "beta..." or "rc..." for beta releases or release candidates
//! - "project..." for version containing project-specific fixes
//#define OCC_VERSION_DEVELOPMENT "dev"
#define OCC_VERSION_DEVELOPMENT "dev"
// Derived (manually): version as real and string (major.minor)
#define OCC_VERSION 7.7
#define OCC_VERSION_STRING "7.7"
#define OCC_VERSION_COMPLETE "7.7.2"
#define OCC_VERSION 7.8
#define OCC_VERSION_STRING "7.8"
#define OCC_VERSION_COMPLETE "7.8.0"
//! Derived: extended version as string ("major.minor.maintenance.dev")
#ifdef OCC_VERSION_DEVELOPMENT

View File

@@ -2,9 +2,7 @@
// This file is generated, do not modify it directly; edit source file step.lex instead.
// Pre-include stdlib.h to avoid redefinition of integer type macros (INT8_MIN and similar in generated code)
#if !defined(_MSC_VER) || (_MSC_VER >= 1600) // Visual Studio 2010+
#include "stdint.h"
#endif
#include <Standard_TypeDef.hxx>
#define YY_INT_ALIGNED short int

View File

@@ -33,9 +33,7 @@
// This file is generated, do not modify it directly; edit source file step.lex instead.
// Pre-include stdlib.h to avoid redefinition of integer type macros (INT8_MIN and similar in generated code)
#if !defined(_MSC_VER) || (_MSC_VER >= 1600) // Visual Studio 2010+
#include "stdint.h"
#endif
#include <Standard_TypeDef.hxx>
}
%{

View File

@@ -1,10 +0,0 @@
puts "========================"
puts "0033414: Modeling Algorithms - Access violation during executing BRepAlgoAPI_Section::Build()"
puts "========================"
set filepath1 [locate_data_file "bug33414_1.brep"]
set filepath2 [locate_data_file "bug33414_2.brep"]
restore ${filepath1} shape1
restore ${filepath2} shape2
bsection res shape1 shape2
# If bsection didn't cause a crash - everything is OK.

View File

@@ -1,41 +0,0 @@
puts "============"
puts "0031956: Visualization - provide Image_AlienPixMap::Save() writing into a memory buffer instead of a file"
puts "============"
puts ""
set anImg1 [locate_data_file chataignier.gif]
set anImg2 [locate_data_file hatch_1.png]
pload VISUALIZATION QAcommands
vclear
vinit View1
vtop
OCC30182 t $anImg1 -fileName; vfit
vdump $imagedir/${casename}_1.png
OCC30182 t $anImg2 -fileName; vfit
vdump $imagedir/${casename}_2.png
vclear
OCC31956 t $anImg1; vfit
vdump $imagedir/${casename}_test_1.png
OCC31956 t $anImg2; vfit
vdump $imagedir/${casename}_test_2.png
vclear
OCC31956 t $anImg1 -stream $imagedir/${casename}_temp_1.gif; vfit
vdump $imagedir/${casename}_test_1s.png
OCC31956 t $anImg2 -stream $imagedir/${casename}_temp_2.png; vfit
vdump $imagedir/${casename}_test_2s.png
if { [diffimage $imagedir/${casename}_test_1.png $imagedir/${casename}_1.png -toleranceOfColor 0.1] != 0 } { puts "Error difference in 1st image" }
if { [diffimage $imagedir/${casename}_test_2.png $imagedir/${casename}_2.png -toleranceOfColor 0.1] != 0 } { puts "Error difference in 2nd image" }
if { [diffimage $imagedir/${casename}_test_1s.png $imagedir/${casename}_1.png -toleranceOfColor 0.1] != 0 } { puts "Error difference in 1st image (using stream)" }
if { [diffimage $imagedir/${casename}_test_2s.png $imagedir/${casename}_2.png -toleranceOfColor 0.1] != 0 } { puts "Error difference in 2nd image (using stream)" }