1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-09-08 14:17:06 +03:00

Compare commits

..

1 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
49 changed files with 252 additions and 1641 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. 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. 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. 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. 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. 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. 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. 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. Avoid hiding the global *new* operator.

View File

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

View File

@@ -1047,13 +1047,11 @@ bool AIS_ViewController::UpdateMousePosition (const Graphic3d_Vec2i& thePoint,
: 0.0; : 0.0;
if (double (Abs (aDelta.x())) > aZoomTol) if (double (Abs (aDelta.x())) > aZoomTol)
{ {
UpdateZoom (Aspect_ScrollDelta (aDelta.x())); if (UpdateZoom (Aspect_ScrollDelta (aDelta.x())))
{
myUI.Dragging.ToMove = true; toUpdateView = true;
myUI.Dragging.PointTo = thePoint; }
myMouseProgressPoint = thePoint; myMouseProgressPoint = thePoint;
toUpdateView = true;
} }
break; break;
} }
@@ -1077,6 +1075,7 @@ bool AIS_ViewController::UpdateMousePosition (const Graphic3d_Vec2i& thePoint,
} }
aDelta.y() = -aDelta.y(); aDelta.y() = -aDelta.y();
myMouseProgressPoint = thePoint;
if (myUI.Panning.ToPan) if (myUI.Panning.ToPan)
{ {
myUI.Panning.Delta += aDelta; myUI.Panning.Delta += aDelta;
@@ -1086,12 +1085,6 @@ bool AIS_ViewController::UpdateMousePosition (const Graphic3d_Vec2i& thePoint,
myUI.Panning.ToPan = true; myUI.Panning.ToPan = true;
myUI.Panning.Delta = aDelta; myUI.Panning.Delta = aDelta;
} }
myUI.Dragging.ToMove = true;
myUI.Dragging.PointTo = thePoint;
myMouseProgressPoint = thePoint;
toUpdateView = true; toUpdateView = true;
} }
break; break;
@@ -3060,8 +3053,6 @@ void AIS_ViewController::handleDynamicHighlight (const Handle(AIS_InteractiveCon
OnObjectDragged (theCtx, theView, AIS_DragAction_Update); OnObjectDragged (theCtx, theView, AIS_DragAction_Update);
myGL.OrbitRotation.ToRotate = false; myGL.OrbitRotation.ToRotate = false;
myGL.ViewRotation .ToRotate = false; myGL.ViewRotation .ToRotate = false;
myGL.Panning .ToPan = false;
myGL.ZoomActions.Clear();
} }
} }
} }

View File

@@ -1177,45 +1177,6 @@ void BRepOffset_BuildOffsetFaces::IntersectTrimmedEdges (const Message_ProgressR
UpdateIntersectedEdges (aLA, aGFE); UpdateIntersectedEdges (aLA, aGFE);
} }
namespace
{
//=======================================================================
//function : CheckConnectionsOfFace
//purpose : Checks number of connections for theFace with theLF
// Returns true if number of connections more than 1
//=======================================================================
static Standard_Boolean checkConnectionsOfFace(const TopoDS_Shape& theFace,
const TopTools_ListOfShape& theLF)
{
TopTools_IndexedMapOfShape aShapeVert;
for (TopTools_ListOfShape::Iterator aFImIterator(theLF); aFImIterator.More(); aFImIterator.Next())
{
const TopoDS_Shape& aShape = aFImIterator.Value();
if (aShape.IsSame(theFace))
{
continue;
}
TopExp::MapShapes(aShape, TopAbs_VERTEX, aShapeVert);
}
Standard_Integer aNbConnections = 0;
TopTools_IndexedMapOfShape aFaceVertices;
TopExp::MapShapes(theFace, TopAbs_VERTEX, aFaceVertices);
for (TopTools_IndexedMapOfShape::Iterator aVertIter(aFaceVertices); aVertIter.More(); aVertIter.Next())
{
const TopoDS_Shape& aVert = aVertIter.Value();
if (aShapeVert.Contains(aVert))
{
++aNbConnections;
}
if (aNbConnections > 1)
{
return Standard_True;
}
}
return Standard_False;
}
}
//======================================================================= //=======================================================================
//function : BuildSplitsOfFaces //function : BuildSplitsOfFaces
//purpose : Building the splits of offset faces and //purpose : Building the splits of offset faces and
@@ -1307,10 +1268,6 @@ void BRepOffset_BuildOffsetFaces::BuildSplitsOfFaces (const Message_ProgressRang
for (TopTools_ListIteratorOfListOfShape aItLFIm (aLFImages1); aItLFIm.More();) for (TopTools_ListIteratorOfListOfShape aItLFIm (aLFImages1); aItLFIm.More();)
{ {
Standard_Boolean bAllInv = Standard_True; Standard_Boolean bAllInv = Standard_True;
// Additional check for artificial case
// if current image face consist only of edges from aMapEInv and aMENInv
// then recheck current face for the futher processing
Standard_Boolean aToReCheckFace = bArtificialCase;
const TopoDS_Shape& aFIm = aItLFIm.Value(); const TopoDS_Shape& aFIm = aItLFIm.Value();
TopExp_Explorer aExpE (aFIm, TopAbs_EDGE); TopExp_Explorer aExpE (aFIm, TopAbs_EDGE);
for (; aExpE.More(); aExpE.Next()) for (; aExpE.More(); aExpE.Next())
@@ -1321,19 +1278,12 @@ void BRepOffset_BuildOffsetFaces::BuildSplitsOfFaces (const Message_ProgressRang
bAllInv = Standard_False; bAllInv = Standard_False;
if (!aMENInv.Contains (aE)) if (!aMENInv.Contains (aE))
{ {
aToReCheckFace = Standard_False;
break; break;
} }
} }
} }
// if current image face is to recheck then check number of connections for this face //
// with other image faces for current face if (!aExpE.More())
if (!aExpE.More() && aToReCheckFace)
{
aToReCheckFace = checkConnectionsOfFace(aFIm, aLFImages1);
}
// do not delete image face from futher processing if aToReCheckFace is true
if (!aExpE.More() && !aToReCheckFace)
{ {
if (bAllInv) if (bAllInv)
{ {

View File

@@ -42,12 +42,9 @@
#include <Geom2d_Circle.hxx> #include <Geom2d_Circle.hxx>
#include <Geom2dAPI_Interpolate.hxx> #include <Geom2dAPI_Interpolate.hxx>
#include <Geom2d_TrimmedCurve.hxx> #include <Geom2d_TrimmedCurve.hxx>
#include <Message.hxx>
#include <TopoDS.hxx> #include <TopoDS.hxx>
#include <TopoDS_Shape.hxx> #include <TopoDS_Shape.hxx>
#include <TopoDS_Wire.hxx> #include <TopoDS_Wire.hxx>
#include <ShapeFix_Wire.hxx>
#include <ShapeFix_Edge.hxx>
#include <DBRep.hxx> #include <DBRep.hxx>
#include <DBRep_DrawableShape.hxx> #include <DBRep_DrawableShape.hxx>
@@ -274,142 +271,6 @@ static Standard_Integer wire(Draw_Interpretor& di, Standard_Integer n, const cha
return 0; return 0;
} }
//=======================================================================
// strongwire
//=======================================================================
static Standard_Integer strongwire(Draw_Interpretor& theDI, Standard_Integer theArgC, const char** theArgV)
{
enum StrongWireMode {
StrongWireMode_FixTolerance = 1,
StrongWireMode_Approximation = 2,
StrongWireMode_KeepCurveType = 3
};
BRep_Builder aB;
TopoDS_Wire aWire;
aB.MakeWire(aWire);
if (theArgC < 3)
return 1;
// Tolerance
double aTolerance = Precision::Confusion();
// mode
StrongWireMode aMode = StrongWireMode_KeepCurveType;
// add edges
for (Standard_Integer anArgIter = 2; anArgIter < theArgC; anArgIter++)
{
TCollection_AsciiString aParam(theArgV[anArgIter]);
if (aParam == "-t")
{
anArgIter++;
if (anArgIter < theArgC)
aTolerance = Draw::Atof(theArgV[anArgIter]);
}
else if (aParam == "-m")
{
anArgIter++;
if (anArgIter < theArgC)
{
if (aParam == "keepType" || Draw::Atoi(theArgV[anArgIter]) == 1)
{
aMode = StrongWireMode_KeepCurveType;
continue;
}
else if (aParam == "approx" || Draw::Atoi(theArgV[anArgIter]) == 2)
{
aMode = StrongWireMode_Approximation;
continue;
}
else if (aParam == "fixTol" || Draw::Atoi(theArgV[anArgIter]) == 3)
{
aMode = StrongWireMode_FixTolerance;
continue;
}
}
}
else
{
TopoDS_Shape aShape = DBRep::Get(theArgV[anArgIter]);
if (aShape.IsNull())
Standard_NullObject::Raise("Shape for wire construction is null");
if (aShape.ShapeType() == TopAbs_EDGE || aShape.ShapeType() == TopAbs_WIRE)
{
TopExp_Explorer anExp(aShape, TopAbs_EDGE);
for (; anExp.More(); anExp.Next())
aB.Add(aWire, TopoDS::Edge(anExp.Current()));
}
else
Standard_TypeMismatch::Raise("Shape for wire construction is neither an edge nor a wire");
}
}
// fix edges order
Handle(ShapeFix_Wire) aFW = new ShapeFix_Wire;
aFW->Load(aWire);
aFW->FixReorder();
if (aFW->StatusReorder(ShapeExtend_FAIL1))
{
Message::SendFail() << "Error: Wire construction failed: several loops detected";
return 1;
}
else if (aFW->StatusReorder(ShapeExtend_FAIL))
{
Message::SendFail() << "Wire construction failed";
return 1;
}
bool isClosed = false;
Handle(ShapeAnalysis_Wire) aSaw = aFW->Analyzer();
if (aSaw->CheckGap3d(1)) // between last and first edges
{
Standard_Real aDist = aSaw->MinDistance3d();
if (aDist < aTolerance)
isClosed = true;
}
aFW->ClosedWireMode() = isClosed;
aFW->FixConnected(aTolerance);
if (aMode == StrongWireMode_KeepCurveType)
aFW->FixCurves();
if (aFW->StatusConnected(ShapeExtend_FAIL))
{
Message::SendFail() << "Wire construction failed: cannot build connected wire";
return 1;
}
if (aFW->StatusConnected(ShapeExtend_DONE3))
{
if (aMode != StrongWireMode_Approximation)
aFW->SetPrecision(aTolerance);
aFW->FixGapsByRangesMode() = Standard_True;
if (aFW->FixGaps3d())
{
Handle(ShapeExtend_WireData) sbwd = aFW->WireData();
Handle(ShapeFix_Edge) aFe = new ShapeFix_Edge;
for (Standard_Integer anIdx = 1; anIdx <= sbwd->NbEdges(); anIdx++)
{
TopoDS_Edge aEdge = TopoDS::Edge(sbwd->Edge(anIdx));
aFe->FixVertexTolerance(aEdge);
aFe->FixSameParameter(aEdge);
}
}
else if (aFW->StatusGaps3d(ShapeExtend_FAIL))
{
Message::SendFail() << "Wire construction failed: cannot fix 3d gaps";
return 1;
}
}
aWire = aFW->WireAPIMake();
DBRep::Set(theArgV[1], aWire);
return 0;
}
//======================================================================= //=======================================================================
// mkedge // mkedge
//======================================================================= //=======================================================================
@@ -2136,10 +1997,6 @@ void BRepTest::CurveCommands(Draw_Interpretor& theCommands)
"wire wirename [-unsorted] e1/w1 [e2/w2 ...]",__FILE__, "wire wirename [-unsorted] e1/w1 [e2/w2 ...]",__FILE__,
wire,g); wire,g);
theCommands.Add("strongwire",
"strongwire wirename e1/w1 [e2/w2 ...] [-t tol] [-m mode(keepType/1 | approx/2 | fixTol/3)]", __FILE__,
strongwire, g);
theCommands.Add("profile", theCommands.Add("profile",
"profile, no args to get help",__FILE__, "profile, no args to get help",__FILE__,
profile,g); profile,g);

View File

@@ -538,6 +538,7 @@ Standard_Boolean DE_Wrapper::FindProvider(const TCollection_AsciiString& thePath
{ {
theProvider = aNode->BuildProvider(); theProvider = aNode->BuildProvider();
aNode->GlobalParameters = GlobalParameters; aNode->GlobalParameters = GlobalParameters;
theProvider->SetNode(aNode);
return Standard_True; return Standard_True;
} }
} }

View File

@@ -125,7 +125,7 @@ Handle(DE_ConfigurationNode) DEXCAFCascade_ConfigurationNode::Copy() const
//======================================================================= //=======================================================================
Handle(DE_Provider) DEXCAFCascade_ConfigurationNode::BuildProvider() Handle(DE_Provider) DEXCAFCascade_ConfigurationNode::BuildProvider()
{ {
return new DEXCAFCascade_Provider (this); return new DEXCAFCascade_Provider();
} }
//======================================================================= //=======================================================================

View File

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

View File

@@ -1,7 +1,5 @@
// Pre-include stdlib.h to avoid redefinition of integer type macros (INT8_MIN and similar in generated code) // 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 <Standard_TypeDef.hxx>
#include "stdint.h"
#endif
#define YY_INT_ALIGNED short int #define YY_INT_ALIGNED short int

View File

@@ -609,7 +609,7 @@ void GeomFill_SectionPlacement::Perform(const Handle(Adaptor3d_Curve)& Path,
myAdpSection.LastParameter(), myAdpSection.LastParameter(),
Path->Resolution(Tol/100), Path->Resolution(Tol/100),
myAdpSection.Resolution(Tol/100)); myAdpSection.Resolution(Tol/100));
if (Ext.IsDone() && !Ext.IsParallel()) { if (Ext.IsDone()) {
Extrema_POnCurv P1, P2; Extrema_POnCurv P1, P2;
for (ii=1; ii<=Ext.NbExt(); ii++) { for (ii=1; ii<=Ext.NbExt(); ii++) {
distaux = sqrt (Ext.SquareDistance(ii)); distaux = sqrt (Ext.SquareDistance(ii));

View File

@@ -73,7 +73,7 @@ Handle(Transfer_Binder) IGESControl_ActorWrite::Transfer
shape = XSAlgo::AlgoContainer()->ProcessShape( shape, Tol, maxTol, shape = XSAlgo::AlgoContainer()->ProcessShape( shape, Tol, maxTol,
"write.iges.resource.name", "write.iges.resource.name",
"write.iges.sequence", info, "write.iges.sequence", info,
theProgress, false, TopAbs_EDGE); theProgress );
// modified by NIZHNY-EAP Tue Aug 29 11:17:01 2000 ___END___ // modified by NIZHNY-EAP Tue Aug 29 11:17:01 2000 ___END___
BRepToIGES_BREntity BR0; BR0.SetModel(modl); BR0.SetTransferProcess(FP); BRepToIGES_BREntity BR0; BR0.SetModel(modl); BR0.SetTransferProcess(FP);

View File

@@ -92,7 +92,7 @@ Standard_Boolean IGESControl_Writer::AddShape (const TopoDS_Shape& theShape,
TopoDS_Shape Shape = XSAlgo::AlgoContainer()->ProcessShape( theShape, Tol, maxTol, TopoDS_Shape Shape = XSAlgo::AlgoContainer()->ProcessShape( theShape, Tol, maxTol,
"write.iges.resource.name", "write.iges.resource.name",
"write.iges.sequence", info, "write.iges.sequence", info,
aPS.Next(), false, TopAbs_EDGE); aPS.Next());
if (!aPS.More()) if (!aPS.More())
return Standard_False; return Standard_False;

View File

@@ -198,7 +198,7 @@ Handle(Transfer_Binder) IGESToBRep_Actor::Transfer
"read.iges.resource.name", "read.iges.resource.name",
"read.iges.sequence", "read.iges.sequence",
info, mymodel->ReShape(), info, mymodel->ReShape(),
aPS.Next(), false, TopAbs_EDGE); aPS.Next());
XSAlgo::AlgoContainer()->MergeTransferInfo(TP, info, nbTPitems); XSAlgo::AlgoContainer()->MergeTransferInfo(TP, info, nbTPitems);
} }

View File

@@ -552,7 +552,7 @@ Standard_Boolean IGESToBRep_Reader::Transfer(const Standard_Integer num,
shape = XSAlgo::AlgoContainer()->ProcessShape( shape, eps*CAS.GetUnitFactor(), CAS.GetMaxTol(), shape = XSAlgo::AlgoContainer()->ProcessShape( shape, eps*CAS.GetUnitFactor(), CAS.GetMaxTol(),
"read.iges.resource.name", "read.iges.resource.name",
"read.iges.sequence", info, "read.iges.sequence", info,
aPS.Next(), false, TopAbs_EDGE); aPS.Next() );
if (aPS.UserBreak()) if (aPS.UserBreak())
return Standard_False; return Standard_False;

View File

@@ -135,10 +135,6 @@ namespace
Image_FreeImageStream (std::istream& theStream) Image_FreeImageStream (std::istream& theStream)
: myIStream (&theStream), myOStream (NULL), myInitPos (theStream.tellg()) {} : 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. //! Get io object.
FreeImageIO GetFiIO() const FreeImageIO GetFiIO() const
{ {
@@ -147,15 +143,12 @@ namespace
if (myIStream != NULL) if (myIStream != NULL)
{ {
anIo.read_proc = readProc; anIo.read_proc = readProc;
anIo.seek_proc = seekProcIn; anIo.seek_proc = seekProc;
anIo.tell_proc = tellProcIn; anIo.tell_proc = tellProc;
} }
if (myOStream != NULL) if (myOStream != NULL)
{ {
anIo.write_proc = writeProc; 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; return anIo;
} }
@@ -190,7 +183,7 @@ namespace
} }
//! Simulate fseek(). //! 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; Image_FreeImageStream* aThis = (Image_FreeImageStream* )theHandle;
if (aThis->myIStream == NULL) if (aThis->myIStream == NULL)
@@ -223,53 +216,13 @@ namespace
return isSeekDone ? 0 : -1; 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(). //! Simulate ftell().
static long DLL_CALLCONV tellProcIn (fi_handle theHandle) static long DLL_CALLCONV tellProc (fi_handle theHandle)
{ {
Image_FreeImageStream* aThis = (Image_FreeImageStream* )theHandle; Image_FreeImageStream* aThis = (Image_FreeImageStream* )theHandle;
const long aPos = aThis->myIStream != NULL ? (long )(aThis->myIStream->tellg() - aThis->myInitPos) : 0; const long aPos = aThis->myIStream != NULL ? (long )(aThis->myIStream->tellg() - aThis->myInitPos) : 0;
return aPos; 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: private:
std::istream* myIStream; std::istream* myIStream;
std::ostream* myOStream; std::ostream* myOStream;
@@ -285,37 +238,6 @@ namespace
return aGuid; 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. //! Sentry over IUnknown pointer.
template<class T> class Image_ComPtr template<class T> class Image_ComPtr
{ {
@@ -424,11 +346,7 @@ namespace
// purpose : // purpose :
// ======================================================================= // =======================================================================
Image_AlienPixMap::Image_AlienPixMap() Image_AlienPixMap::Image_AlienPixMap()
#ifdef HAVE_WINCODEC
: myPalette (NULL)
#else
: myLibImage (NULL) : myLibImage (NULL)
#endif
{ {
SetTopDown (false); SetTopDown (false);
} }
@@ -587,12 +505,6 @@ void Image_AlienPixMap::Clear()
FreeImage_Unload (myLibImage); FreeImage_Unload (myLibImage);
myLibImage = NULL; myLibImage = NULL;
} }
#elif defined(HAVE_WINCODEC)
if (myPalette != NULL)
{
myPalette->Release();
myPalette = NULL;
}
#elif defined(__EMSCRIPTEN__) #elif defined(__EMSCRIPTEN__)
if (myLibImage != NULL) if (myLibImage != NULL)
{ {
@@ -623,7 +535,7 @@ bool Image_AlienPixMap::IsTopDownDefault()
// ======================================================================= // =======================================================================
#ifdef HAVE_FREEIMAGE #ifdef HAVE_FREEIMAGE
bool Image_AlienPixMap::Load (const Standard_Byte* theData, bool Image_AlienPixMap::Load (const Standard_Byte* theData,
const Standard_Size theLength, Standard_Size theLength,
const TCollection_AsciiString& theImagePath) const TCollection_AsciiString& theImagePath)
{ {
Clear(); Clear();
@@ -793,7 +705,7 @@ bool Image_AlienPixMap::Load (std::istream& theStream,
#elif defined(HAVE_WINCODEC) #elif defined(HAVE_WINCODEC)
bool Image_AlienPixMap::Load (const Standard_Byte* theData, bool Image_AlienPixMap::Load (const Standard_Byte* theData,
const Standard_Size theLength, Standard_Size theLength,
const TCollection_AsciiString& theFileName) const TCollection_AsciiString& theFileName)
{ {
Clear(); Clear();
@@ -839,7 +751,7 @@ bool Image_AlienPixMap::Load (const Standard_Byte* theData,
|| aFrameCount < 1 || aFrameCount < 1
|| aWicDecoder->GetFrame (0, &aWicFrameDecode.ChangePtr()) != S_OK || aWicDecoder->GetFrame (0, &aWicFrameDecode.ChangePtr()) != S_OK
|| aWicFrameDecode->GetSize (&aFrameSizeX, &aFrameSizeY) != S_OK || aWicFrameDecode->GetSize (&aFrameSizeX, &aFrameSizeY) != S_OK
|| aWicFrameDecode->GetPixelFormat (&aWicPixelFormat) != S_OK) || aWicFrameDecode->GetPixelFormat (&aWicPixelFormat))
{ {
Message::SendFail ("Error: cannot get WIC Image Frame"); Message::SendFail ("Error: cannot get WIC Image Frame");
return false; 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"); Message::SendFail ("Error: cannot convert WIC Image Frame to RGB format");
return false; return false;
} }
aWicFrameDecode.Nullify();
} }
if (!Image_PixMap::InitTrash (aPixelFormat, aFrameSizeX, aFrameSizeY)) if (!Image_PixMap::InitTrash (aPixelFormat, aFrameSizeX, aFrameSizeY))
@@ -864,37 +777,17 @@ bool Image_AlienPixMap::Load (const Standard_Byte* theData,
return false; 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(); IWICBitmapSource* aWicSrc = aWicFrameDecode.get();
if(!aWicConvertedFrame.IsNull()) if(!aWicConvertedFrame.IsNull())
{ {
aWicSrc = aWicConvertedFrame.get(); 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) if (aWicSrc->CopyPixels (NULL, (UINT )SizeRowBytes(), (UINT )SizeBytes(), ChangeData()) != S_OK)
{ {
Message::SendFail ("Error: cannot copy pixels from WIC Image"); Message::SendFail ("Error: cannot copy pixels from WIC Image");
return false; return false;
} }
SetTopDown (isTopDown); SetTopDown (true);
return true; return true;
} }
bool Image_AlienPixMap::Load (std::istream& theStream, bool Image_AlienPixMap::Load (std::istream& theStream,
@@ -931,7 +824,7 @@ bool Image_AlienPixMap::Load (std::istream& ,
return false; return false;
} }
bool Image_AlienPixMap::Load (const Standard_Byte* theData, bool Image_AlienPixMap::Load (const Standard_Byte* theData,
const Standard_Size theLength, Standard_Size theLength,
const TCollection_AsciiString& theImagePath) const TCollection_AsciiString& theImagePath)
{ {
Clear(); Clear();
@@ -964,7 +857,7 @@ bool Image_AlienPixMap::Load (std::istream& ,
return false; return false;
} }
bool Image_AlienPixMap::Load (const Standard_Byte* , bool Image_AlienPixMap::Load (const Standard_Byte* ,
const Standard_Size , Standard_Size ,
const TCollection_AsciiString& ) const TCollection_AsciiString& )
{ {
Clear(); Clear();
@@ -1014,52 +907,11 @@ bool Image_AlienPixMap::savePPM (const TCollection_AsciiString& theFileName) con
return true; 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 // function : Save
// purpose : // purpose :
// ======================================================================= // =======================================================================
bool Image_AlienPixMap::Save (Standard_Byte* theBuffer, bool Image_AlienPixMap::Save (const TCollection_AsciiString& theFileName)
const Standard_Size theLength,
const TCollection_AsciiString& theFileName)
{ {
#ifdef HAVE_FREEIMAGE #ifdef HAVE_FREEIMAGE
if (myLibImage == NULL) if (myLibImage == NULL)
@@ -1087,399 +939,10 @@ bool Image_AlienPixMap::Save (Standard_Byte* theBuffer,
SetTopDown (false); 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 // FreeImage doesn't provide flexible format conversion API
// so we should perform multiple conversions in some cases! // so we should perform multiple conversions in some cases!
switch (theFormat) FIBITMAP* anImageToDump = myLibImage;
switch (anImageFormat)
{ {
case FIF_PNG: case FIF_PNG:
case FIF_BMP: case FIF_BMP:
@@ -1510,7 +973,7 @@ FIBITMAP* Image_AlienPixMap::getImageToDump (const Standard_Integer theFormat)
aTmpBitmap = FreeImage_ConvertToType (myLibImage, FIT_BITMAP); aTmpBitmap = FreeImage_ConvertToType (myLibImage, FIT_BITMAP);
if (aTmpBitmap == NULL) if (aTmpBitmap == NULL)
{ {
return NULL; return false;
} }
} }
@@ -1523,7 +986,7 @@ FIBITMAP* Image_AlienPixMap::getImageToDump (const Standard_Integer theFormat)
} }
if (aTmpBitmap24 == NULL) if (aTmpBitmap24 == NULL)
{ {
return NULL; return false;
} }
aTmpBitmap = aTmpBitmap24; aTmpBitmap = aTmpBitmap24;
} }
@@ -1568,7 +1031,7 @@ FIBITMAP* Image_AlienPixMap::getImageToDump (const Standard_Integer theFormat)
anImageToDump = FreeImage_ConvertToType (myLibImage, FIT_BITMAP); anImageToDump = FreeImage_ConvertToType (myLibImage, FIT_BITMAP);
if (anImageToDump == NULL) if (anImageToDump == NULL)
{ {
return NULL; return false;
} }
} }
@@ -1581,13 +1044,170 @@ FIBITMAP* Image_AlienPixMap::getImageToDump (const Standard_Integer theFormat)
} }
if (aTmpBitmap24 == NULL) if (aTmpBitmap24 == NULL)
{ {
return NULL; return false;
} }
anImageToDump = aTmpBitmap24; anImageToDump = aTmpBitmap24;
} }
break; 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 #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> #include <Image_PixMap.hxx>
class TCollection_AsciiString; class TCollection_AsciiString;
struct IWICPalette;
struct FIBITMAP; struct FIBITMAP;
//! Image class that support file reading/writing operations using auxiliary image library. //! Image class that support file reading/writing operations using auxiliary image library.
@@ -58,41 +57,21 @@ public:
const TCollection_AsciiString& theFileName); const TCollection_AsciiString& theFileName);
//! Read image data from memory buffer. //! Read image data from memory buffer.
//! @param[in] theData memory pointer to read from; //! @param theData memory pointer to read from;
//! when NULL, function will attempt to open theFileName file //! when NULL, function will attempt to open theFileName file
//! @param[in] theLength memory buffer length //! @param theLength memory buffer length
//! @param[in] theFileName optional file name //! @param theFileName optional file name
Standard_EXPORT bool Load (const Standard_Byte* theData, Standard_EXPORT bool Load (const Standard_Byte* theData,
const Standard_Size theLength, Standard_Size theLength,
const TCollection_AsciiString& theFileName); const TCollection_AsciiString& theFileName);
//! Write image data to file. //! Write image data to file using file extension to determine compression format.
//! @param[in] theFileName file name to save Standard_EXPORT bool Save (const TCollection_AsciiString& theFileName);
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);
//! Initialize image plane with required dimensions. //! Initialize image plane with required dimensions.
//! @param[in] thePixelFormat if specified pixel format doesn't supported by image library //! thePixelFormat - if specified pixel format doesn't supported by image library
//! than nearest supported will be used instead! //! than nearest supported will be used instead!
//! @param[in] theSizeRowBytes may be ignored by this class and required alignment 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, Standard_EXPORT virtual bool InitTrash (Image_Format thePixelFormat,
const Standard_Size theSizeX, const Standard_Size theSizeX,
const Standard_Size theSizeY, const Standard_Size theSizeY,
@@ -105,13 +84,12 @@ public:
Standard_EXPORT virtual void Clear() Standard_OVERRIDE; Standard_EXPORT virtual void Clear() Standard_OVERRIDE;
//! Performs gamma correction on image. //! 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); Standard_EXPORT bool AdjustGamma (const Standard_Real theGammaCorr);
#if !defined(HAVE_FREEIMAGE) && defined(_WIN32) private:
//! Returns image palette.
IWICPalette* GetPalette() const { return myPalette; } FIBITMAP* myLibImage;
#endif
private: private:
@@ -130,13 +108,6 @@ private:
//! Built-in PPM export //! Built-in PPM export
Standard_EXPORT bool savePPM (const TCollection_AsciiString& theFileName) const; 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) 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 aFrmUInd = theUIndex + myUIndMin - 1;
Standard_Integer aFrmVInd = theVIndex + myVIndMin - 1; Standard_Integer aFrmVInd = theVIndex + myVIndMin - 1;
if (myGridPoints.IsNull() || aFrmUInd > myUIndMax || aFrmVInd > myVIndMax) if (aFrmUInd > myUIndMax || aFrmVInd > myVIndMax)
return gp::Origin(); return gp::Origin();
return myGridPoints->Value(aFrmUInd, aFrmVInd); return myGridPoints->Value(aFrmUInd, aFrmVInd);
@@ -235,7 +235,7 @@ Standard_Real IntTools_SurfaceRangeLocalizeData::GetUParamInFrame
{ {
Standard_Integer aFrmInd = theIndex + myUIndMin - 1; Standard_Integer aFrmInd = theIndex + myUIndMin - 1;
if (myUParams.IsNull() || aFrmInd > myUIndMax) if (aFrmInd > myUIndMax)
return Precision::Infinite(); return Precision::Infinite();
return myUParams->Value(aFrmInd); return myUParams->Value(aFrmInd);
@@ -246,7 +246,7 @@ Standard_Real IntTools_SurfaceRangeLocalizeData::GetVParamInFrame
{ {
Standard_Integer aFrmInd = theIndex + myVIndMin - 1; Standard_Integer aFrmInd = theIndex + myVIndMin - 1;
if (myVParams.IsNull() || aFrmInd > myVIndMax) if (aFrmInd > myVIndMax)
return Precision::Infinite(); return Precision::Infinite();
return myVParams->Value(aFrmInd); return myVParams->Value(aFrmInd);

View File

@@ -387,11 +387,11 @@ static Standard_Integer OCC361bug (Draw_Interpretor& di, Standard_Integer nb, co
//function : OCC30182 //function : OCC30182
//purpose : Testing different interfaces of Image_AlienPixMap::Load() //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()) if (ViewerTest::CurrentView().IsNull())
{ {
di << "Error: no active view\n"; std::cout << "Error: no active view\n";
return 1; return 1;
} }
@@ -430,13 +430,13 @@ static Standard_Integer OCC30182 (Draw_Interpretor& di, Standard_Integer theNbAr
} }
else else
{ {
di << "Syntax error at '" << anArg << "'\n"; std::cout << "Syntax error at '" << anArg << "'\n";
return 1; return 1;
} }
} }
if (anImgPath.IsEmpty()) if (anImgPath.IsEmpty())
{ {
di << "Syntax error: wrong number of arguments\n"; std::cout << "Syntax error: wrong number of arguments\n";
return 1; 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); std::shared_ptr<std::istream> aFile = aFileSystem->OpenIStream (anImgPath, std::ios::in | std::ios::binary);
if (aFile.get() == NULL) 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; return 1;
} }
if (anOffset != 0) if (anOffset != 0)
@@ -469,13 +469,13 @@ static Standard_Integer OCC30182 (Draw_Interpretor& di, Standard_Integer theNbAr
aFile->seekg (anOffset); aFile->seekg (anOffset);
if (aLen <= 0) if (aLen <= 0)
{ {
di << "Syntax error: wrong offset\n"; std::cout << "Syntax error: wrong offset\n";
return 1; return 1;
} }
NCollection_Array1<Standard_Byte> aBuff (1, aLen); NCollection_Array1<Standard_Byte> aBuff (1, aLen);
if (!aFile->read ((char* )&aBuff.ChangeFirst(), aBuff.Size())) 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; return 1;
} }
if (!anImage->Load (&aBuff.ChangeFirst(), aBuff.Size(), anImgPath)) if (!anImage->Load (&aBuff.ChangeFirst(), aBuff.Size(), anImgPath))
@@ -510,107 +510,6 @@ static Standard_Integer OCC30182 (Draw_Interpretor& di, Standard_Integer theNbAr
return 0; 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) { void QABugs::Commands_1(Draw_Interpretor& theCommands) {
const char *group = "QABugs"; const char *group = "QABugs";
@@ -628,7 +527,5 @@ void QABugs::Commands_1(Draw_Interpretor& theCommands) {
theCommands.Add ("OCC30182", theCommands.Add ("OCC30182",
"OCC30182 name image [-offset Start] [-fileName] [-stream] [-memory]\n" "OCC30182 name image [-offset Start] [-fileName] [-stream] [-memory]\n"
"Decodes image either by passing file name, file stream or memory stream", __FILE__, OCC30182, group); "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; return;
} }

View File

@@ -52,19 +52,13 @@
#include <BRepBuilderAPI_MakeEdge.hxx> #include <BRepBuilderAPI_MakeEdge.hxx>
#include <BRepBuilderAPI_MakeVertex.hxx> #include <BRepBuilderAPI_MakeVertex.hxx>
#include <BRepTools.hxx> #include <BRepTools.hxx>
#include <GC_MakeArcOfCircle.hxx>
#include <GC_MakeArcOfEllipse.hxx>
#include <GC_MakeLine.hxx>
#include <Geom2d_Curve.hxx> #include <Geom2d_Curve.hxx>
#include <Geom2d_Line.hxx> #include <Geom2d_Line.hxx>
#include <Geom2d_TrimmedCurve.hxx> #include <Geom2d_TrimmedCurve.hxx>
#include <Geom2dAdaptor_Curve.hxx> #include <Geom2dAdaptor_Curve.hxx>
#include <Geom2dConvert.hxx> #include <Geom2dConvert.hxx>
#include <Geom_Curve.hxx>
#include <Geom_Circle.hxx>
#include <Geom_Ellipse.hxx>
#include <Geom_BezierCurve.hxx>
#include <Geom_BSplineCurve.hxx> #include <Geom_BSplineCurve.hxx>
#include <Geom_Curve.hxx>
#include <Geom_OffsetCurve.hxx> #include <Geom_OffsetCurve.hxx>
#include <Geom_Plane.hxx> #include <Geom_Plane.hxx>
#include <Geom_SphericalSurface.hxx> #include <Geom_SphericalSurface.hxx>
@@ -74,7 +68,6 @@
#include <GeomAdaptor_Curve.hxx> #include <GeomAdaptor_Curve.hxx>
#include <GeomAPI.hxx> #include <GeomAPI.hxx>
#include <GeomAPI_ProjectPointOnCurve.hxx> #include <GeomAPI_ProjectPointOnCurve.hxx>
#include <GeomAPI_ProjectPointOnSurf.hxx>
#include <GeomConvert_CompCurveToBSplineCurve.hxx> #include <GeomConvert_CompCurveToBSplineCurve.hxx>
#include <IntRes2d_IntersectionPoint.hxx> #include <IntRes2d_IntersectionPoint.hxx>
#include <IntRes2d_SequenceOfIntersectionPoint.hxx> #include <IntRes2d_SequenceOfIntersectionPoint.hxx>
@@ -519,25 +512,6 @@ Standard_Boolean ShapeFix_Wire::FixConnected (const Standard_Real prec)
return StatusConnected ( ShapeExtend_DONE ); return StatusConnected ( ShapeExtend_DONE );
} }
//=======================================================================
//function : FixCurves
//purpose :
//=======================================================================
Standard_Boolean ShapeFix_Wire::FixCurves()
{
myStatusConnected = ShapeExtend::EncodeStatus(ShapeExtend_OK);
if (!IsLoaded()) return Standard_False;
Standard_Integer stop = (myClosedMode ? 0 : 1);
for (Standard_Integer anIdx = NbEdges(); anIdx > stop; anIdx--)
{
FixCurves(anIdx);
myStatusConnected |= myLastFixStatus;
}
return StatusConnected(ShapeExtend_DONE);
}
//======================================================================= //=======================================================================
//function : FixEdgeCurves //function : FixEdgeCurves
//purpose : //purpose :
@@ -1325,169 +1299,6 @@ Standard_Boolean ShapeFix_Wire::FixConnected (const Standard_Integer num,
return Standard_True; return Standard_True;
} }
//=======================================================================
//function : FixCurves
//purpose :
//=======================================================================
Standard_Boolean ShapeFix_Wire::FixCurves(const Standard_Integer theIdx)
{
// assume fix curves step should be after fix vertices
myLastFixStatus = ShapeExtend::EncodeStatus(ShapeExtend_OK);
if (!IsLoaded() || NbEdges() <= 0)
return Standard_False;
// action: replacing curves in edges
Handle(ShapeExtend_WireData) anSbwd = WireData();
Standard_Integer anIdx = (theIdx > 0 ? theIdx : anSbwd->NbEdges());
TopoDS_Edge anEdge = anSbwd->Edge(anIdx);
Standard_Real aPrec = BRep_Tool::Tolerance(anEdge);
ShapeAnalysis_Edge aSae;
ShapeAnalysis_Wire aSaw;
Handle(Geom_Curve) aCurve3d;
Standard_Real aCurBounds[3];
Standard_Boolean IsReversed = Standard_False;
aSae.Curve3d(anEdge, aCurve3d, aCurBounds[0], aCurBounds[2], IsReversed);
aCurBounds[1] = (aCurBounds[0] + aCurBounds[2]) / 2;
gp_Pnt anEnds[3];
anEnds[0] = BRep_Tool::Pnt(aSae.FirstVertex(anEdge));
aCurve3d->D0(aCurBounds[1], anEnds[1]);
anEnds[2] = BRep_Tool::Pnt(aSae.LastVertex(anEdge));
gp_Pnt aGeomEnds[2];
aCurve3d->D0(aCurBounds[0], aGeomEnds[0]);
aCurve3d->D0(aCurBounds[2], aGeomEnds[1]);
// TODO: precise, if IsReversed flag should be considered here
Standard_Real aGap0 = Min(anEnds[0].Distance(aGeomEnds[0]), anEnds[0].Distance(aGeomEnds[1]));
Standard_Real aGap2 = Min(anEnds[2].Distance(aGeomEnds[0]), anEnds[2].Distance(aGeomEnds[1]));
if (Max (aGap0, aGap2) < aPrec) // nothing to do
return true;
if (aCurve3d->IsKind(STANDARD_TYPE(Geom_Circle)))
{
Standard_Real anOldR = Handle(Geom_Circle)::DownCast(aCurve3d)->Circ().Radius();
gp_Vec anArcNorm = gp_Vec(anEnds[2], anEnds[0]) / 2;
gp_Pnt aCenter(anEnds[0].XYZ() - anArcNorm.XYZ());
int aSign = anEnds[1].Distance(aCenter) > anOldR ? 1 : -1; // for arc length > PI
Standard_Real aD = anOldR*anOldR - anArcNorm.SquareMagnitude();
aD = abs(aD) < Precision::Confusion() ? 0. : aD;
Standard_Real anArcR = anOldR + aSign * sqrt(aD);
gp_Ax2 aNormal(aCenter, anArcNorm);
Handle(Geom_Circle) anArc = new Geom_Circle(aNormal, anArcR);
GeomAPI_ProjectPointOnCurve projector(anEnds[1], anArc);
anEnds[1] = projector.NearestPoint();
GC_MakeArcOfCircle arc(anEnds[0], anEnds[1], anEnds[2]);
TopoDS_Edge aNewEdge = BRepBuilderAPI_MakeEdge(arc.Value()).Edge();
anSbwd->Set(aNewEdge, theIdx);
return true;
}
else if (aCurve3d->IsKind(STANDARD_TYPE(Geom_Ellipse)))
{
Handle(Geom_Ellipse) anOld = Handle(Geom_Ellipse)::DownCast(aCurve3d);
Handle(Geom_Plane) aPln = new Geom_Plane(anEnds[0], gp_Vec(anEnds[2], anEnds[0]).Crossed(gp_Vec(anEnds[1], anEnds[0])));
GeomAPI_ProjectPointOnSurf aProjector(anOld->Elips().Location(), aPln);
gp_Pnt anOrigin = aProjector.NearestPoint();
aProjector.Init(anOld->Elips().Location().XYZ() + anOld->Elips().XAxis().Direction().XYZ(), aPln);
gp_Ax2 anAx(anOrigin, aPln->Axis().Direction(), aProjector.NearestPoint().XYZ() - anOrigin.XYZ());
// compute angle
Standard_Real aRec = DBL_MAX;
Standard_Real anAngle = 0.;
Standard_Integer aSplNum = 10;
for (Standard_Integer anIdxI = -aSplNum; anIdxI < aSplNum; ++anIdxI)
{
Handle(Geom_Ellipse) anEll = new Geom_Ellipse(anAx, anOld->MajorRadius(), anOld->MinorRadius());
anEll->Rotate(anAx.Axis(), aPrec*anIdxI / anEll->MajorRadius() / aSplNum);
GeomAPI_ProjectPointOnCurve aProjector1(anEnds[0], anEll);
Standard_Real aDist = 0.;
for (Standard_Integer anIdxJ = 0; anIdxJ < 2; ++anIdxJ)
{
aProjector1.Perform(anEnds[anIdxJ *2]);
aDist += std::fmin (aProjector1.Distance(1), aProjector1.Distance(2));
}
if (aDist < aRec)
{
aRec = aDist;
anAngle = aPrec*anIdxI / anEll->MajorRadius() / aSplNum;
}
}
gp_Elips aTemp(anAx, anOld->MajorRadius(), anOld->MinorRadius());
aTemp.Rotate(anAx.Axis(), anAngle);
// compute shift
gp_Vec aX = aTemp.XAxis().Direction();
gp_Vec aY = aTemp.YAxis().Direction();
gp_Pnt2d aP1((anEnds[0].XYZ() - anOrigin.XYZ()).Dot(aX.XYZ()), (anEnds[0].XYZ() - anOrigin.XYZ()).Dot(aY.XYZ()));
gp_Pnt2d aP2((anEnds[2].XYZ() - anOrigin.XYZ()).Dot(aX.XYZ()), (anEnds[2].XYZ() - anOrigin.XYZ()).Dot(aY.XYZ()));
// x = ky + p linear equation
// where (x, y) shift point,
// k, p constant coefficients
Standard_Real k = 1, p = 0;
Standard_Real R = anOld->MajorRadius();
Standard_Real r = anOld->MinorRadius();
k = (R / r) * (R / r) *
(aP1.Y() - aP2.Y()) / (aP2.X() - aP1.X());
p = -(1. / 2) * (R / r) * (R / r) *
(aP1.Y()*aP1.Y() - aP2.Y()*aP2.Y()) / (aP2.X() - aP1.X()) + aP1.X() / 2 + aP2.X() / 2;
// ax^2 + bx + c = 0 square equation
// a, b, c constant coefficients
Standard_Real a = 0., b = 0., c = 0.;
a = R*R + k*k*r*r;
b = 2 * (k*p*r*r - k*aP1.X()*r*r - aP1.Y()*R*R);
c = aP1.X()*aP1.X()*r*r +
aP1.Y()*aP1.Y()*R*R -
r*r*R*R +
p*p*r*r - 2 * aP1.X()*p*r*r;
Standard_Real y1 = (-b - sqrt(b*b - 4 * a*c)) / 2 / a;
Standard_Real y2 = (-b + sqrt(b*b - 4 * a*c)) / 2 / a;
Standard_Real x1 = k*y1 + p;
Standard_Real x2 = k*y2 + p;
gp_Pnt anOri = anOld->Location();
if (x1*x1 + y1*y1 < x2*x2 + y2*y2)
anOri = anOri.XYZ() + aX.XYZ()*x1 + aY.XYZ()*y1;
else
anOri = anOri.XYZ() + aX.XYZ()*x2 + aY.XYZ()*y2;
aTemp.SetLocation(anOri);
GC_MakeArcOfEllipse anArc(aTemp, anEnds[2], anEnds[0], true);
TopoDS_Edge aNewEdge = BRepBuilderAPI_MakeEdge(anArc.Value()).Edge();
anSbwd->Set(aNewEdge, theIdx);
return true;
}
else if (aCurve3d->IsKind(STANDARD_TYPE(Geom_Line)))
{
TopoDS_Edge aNewEdge = BRepBuilderAPI_MakeEdge(anEnds[2], anEnds[0]).Edge();
anSbwd->Set(aNewEdge, theIdx);
return true;
}
else if (aCurve3d->IsKind(STANDARD_TYPE(Geom_BSplineCurve)))
{
Handle(Geom_BSplineCurve) anOld = Handle(Geom_BSplineCurve)::DownCast(aCurve3d);
Standard_Integer f, l;
int p = anEnds[0].Distance(aGeomEnds[0]) < anEnds[1].Distance(aGeomEnds[0]) ? 0 : 2;
anOld->MovePoint(aCurBounds[0], anEnds[p], 1, 1, f, l);
anOld->MovePoint(aCurBounds[2], anEnds[2-p], anOld->NbPoles(), anOld->NbPoles(), f, l);
return true;
}
else if (aCurve3d->IsKind(STANDARD_TYPE(Geom_BezierCurve)))
{
Handle(Geom_BezierCurve) anOld = Handle(Geom_BezierCurve)::DownCast(aCurve3d);
int p = anEnds[0].Distance(aGeomEnds[0]) < anEnds[1].Distance(aGeomEnds[0]) ? 0 : 2;
anOld->SetPole(1, anEnds[p]);
anOld->SetPole(anOld->NbPoles(), anEnds[2-p]);
return true;
}
// TODO: question: the below code works only for other curve types (not line/arc/circle/ellipse/bspline)
// Is it really needed?
myAnalyzer->CheckConnected(theIdx, aPrec);
if (myAnalyzer->LastCheckStatus(ShapeExtend_FAIL))
myLastFixStatus |= ShapeExtend::EncodeStatus(ShapeExtend_FAIL1);
return true;
}
//======================================================================= //=======================================================================
//function : FixSeam //function : FixSeam

View File

@@ -277,7 +277,6 @@ public:
//! flag ClosedMode is True //! flag ClosedMode is True
//! If <prec> is -1 then MaxTolerance() is taken. //! If <prec> is -1 then MaxTolerance() is taken.
Standard_EXPORT Standard_Boolean FixConnected (const Standard_Real prec = -1.0); Standard_EXPORT Standard_Boolean FixConnected (const Standard_Real prec = -1.0);
Standard_EXPORT Standard_Boolean FixCurves();
//! Groups the fixes dealing with 3d and pcurves of the edges. //! Groups the fixes dealing with 3d and pcurves of the edges.
//! The order of the fixes and the default behaviour are: //! The order of the fixes and the default behaviour are:
@@ -347,7 +346,6 @@ public:
//! Tests with starting preci or, if given greater, <prec> //! Tests with starting preci or, if given greater, <prec>
//! If <prec> is -1 then MaxTolerance() is taken. //! If <prec> is -1 then MaxTolerance() is taken.
Standard_EXPORT Standard_Boolean FixConnected (const Standard_Integer num, const Standard_Real prec); Standard_EXPORT Standard_Boolean FixConnected (const Standard_Integer num, const Standard_Real prec);
Standard_EXPORT Standard_Boolean FixCurves(const Standard_Integer num);
//! Fixes a seam edge //! Fixes a seam edge
//! A Seam edge has two pcurves, one for forward. one for reversed //! A Seam edge has two pcurves, one for forward. one for reversed

View File

@@ -340,22 +340,16 @@ static Standard_Real ComputeMinEdgeSize(const TopTools_SequenceOfShape& theEdges
return MinSize; return MinSize;
} }
//======================================================================= static void FindCoordBounds(const TopTools_SequenceOfShape& theFaces,
//function : FindCoordBounds const TopoDS_Face& theRefFace,
//purpose : Searching for origin of U in 2d space const TopTools_IndexedDataMapOfShapeListOfShape& theMapEF,
// Returns Standard_False if could not find curve on surface const TopTools_MapOfShape& theEdgesMap,
// Returns Standard_True if succeed const Standard_Integer theIndCoord,
//======================================================================= const Standard_Real thePeriod,
static Standard_Boolean FindCoordBounds(const TopTools_SequenceOfShape& theFaces, Standard_Real& theMinCoord,
const TopoDS_Face& theRefFace, Standard_Real& theMaxCoord,
const TopTools_IndexedDataMapOfShapeListOfShape& theMapEF, Standard_Integer& theNumberOfIntervals,
const TopTools_MapOfShape& theEdgesMap, Standard_Integer& theIndFaceMax)
const Standard_Integer theIndCoord,
const Standard_Real thePeriod,
Standard_Real& theMinCoord,
Standard_Real& theMaxCoord,
Standard_Integer& theNumberOfIntervals,
Standard_Integer& theIndFaceMax)
{ {
NCollection_Sequence<std::pair<Standard_Real, Standard_Real>> aPairSeq; NCollection_Sequence<std::pair<Standard_Real, Standard_Real>> aPairSeq;
@@ -378,10 +372,6 @@ static Standard_Boolean FindCoordBounds(const TopTools_SequenceOfShape& theFaces
continue; continue;
Standard_Real fpar, lpar; Standard_Real fpar, lpar;
Handle(Geom2d_Curve) aPCurve = BRep_Tool::CurveOnSurface(anEdge, theRefFace, fpar, lpar); Handle(Geom2d_Curve) aPCurve = BRep_Tool::CurveOnSurface(anEdge, theRefFace, fpar, lpar);
if (aPCurve.IsNull())
{
return Standard_False;
}
UpdateBoundaries (aPCurve, fpar, lpar, theIndCoord, aMinCoord, aMaxCoord); UpdateBoundaries (aPCurve, fpar, lpar, theIndCoord, aMinCoord, aMaxCoord);
} }
@@ -446,7 +436,6 @@ static Standard_Boolean FindCoordBounds(const TopTools_SequenceOfShape& theFaces
theMinCoord = aPairSeq(1).first; theMinCoord = aPairSeq(1).first;
theMaxCoord = aPairSeq(1).second; theMaxCoord = aPairSeq(1).second;
return Standard_True;
} }
static void RelocatePCurvesToNewUorigin(const TopTools_SequenceOfShape& theEdges, static void RelocatePCurvesToNewUorigin(const TopTools_SequenceOfShape& theEdges,
@@ -3308,11 +3297,8 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces(const TopoDS_Shape& theInpShape
//so that all the faces are in [origin, origin + Uperiod] //so that all the faces are in [origin, origin + Uperiod]
Standard_Real aMinCoord, aMaxCoord; //Umin, Umax; Standard_Real aMinCoord, aMaxCoord; //Umin, Umax;
Standard_Integer aNumberOfIntervals, i_face_max; Standard_Integer aNumberOfIntervals, i_face_max;
if (!FindCoordBounds(faces, F_RefFace, aMapEF, edgesMap, ii + 1, aPeriods[ii], FindCoordBounds (faces, F_RefFace, aMapEF, edgesMap, ii+1, aPeriods[ii],
aMinCoord, aMaxCoord, aNumberOfIntervals, i_face_max)) aMinCoord, aMaxCoord, aNumberOfIntervals, i_face_max);
{
break;
}
if (aMaxCoord - aMinCoord > aPeriods[ii] - 1.e-5) if (aMaxCoord - aMinCoord > aPeriods[ii] - 1.e-5)
anIsSeamFound[ii] = Standard_True; anIsSeamFound[ii] = Standard_True;
@@ -3617,10 +3603,6 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces(const TopoDS_Shape& theInpShape
ReconstructMissedSeam (RemovedEdges, F_RefFace, CurEdge, CurVertex, CurPoint, ReconstructMissedSeam (RemovedEdges, F_RefFace, CurEdge, CurVertex, CurPoint,
Uperiod, Vperiod, NextEdge, NextPoint); Uperiod, Vperiod, NextEdge, NextPoint);
if (NextEdge.IsNull())
{
return;
}
} }
else else
return; return;

View File

@@ -17,41 +17,8 @@
#include <cstddef> #include <cstddef>
#include <ctime> #include <ctime>
#include <cstdint>
#include <stdint.h> #include <cinttypes>
#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
#define Standard_False false #define Standard_False false
#define Standard_True true #define Standard_True true

View File

@@ -2,9 +2,7 @@
// This file is generated, do not modify it directly; edit source file step.lex instead. // 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) // 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 <Standard_TypeDef.hxx>
#include "stdint.h"
#endif
#define YY_INT_ALIGNED short int #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. // 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) // 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 <Standard_TypeDef.hxx>
#include "stdint.h"
#endif
} }
%{ %{

View File

@@ -13910,73 +13910,6 @@ static int VSelBvhBuild (Draw_Interpretor& /*theDI*/, Standard_Integer theNbArgs
return 0; return 0;
} }
//=======================================================================
//function : VChangeMouseGesture
//purpose :
//=======================================================================
static int VChangeMouseGesture (Draw_Interpretor&,
Standard_Integer theArgsNb,
const char** theArgVec)
{
Handle(V3d_View) aView = ViewerTest::CurrentView();
if (aView.IsNull())
{
Message::SendFail ("Error: no active viewer");
return 1;
}
NCollection_DoubleMap<TCollection_AsciiString, AIS_MouseGesture> aGestureMap;
{
aGestureMap.Bind ("none", AIS_MouseGesture_NONE);
aGestureMap.Bind ("selectrectangle", AIS_MouseGesture_SelectRectangle);
aGestureMap.Bind ("selectlasso", AIS_MouseGesture_SelectLasso);
aGestureMap.Bind ("zoom", AIS_MouseGesture_Zoom);
aGestureMap.Bind ("zoomwindow", AIS_MouseGesture_ZoomWindow);
aGestureMap.Bind ("pan", AIS_MouseGesture_Pan);
aGestureMap.Bind ("rotateorbit", AIS_MouseGesture_RotateOrbit);
aGestureMap.Bind ("rotateview", AIS_MouseGesture_RotateView);
aGestureMap.Bind ("drag", AIS_MouseGesture_Drag);
}
NCollection_DoubleMap<TCollection_AsciiString, Standard_UInteger> aMouseButtonMap;
{
aMouseButtonMap.Bind ("none", (Standard_UInteger )Aspect_VKeyMouse_NONE);
aMouseButtonMap.Bind ("left", (Standard_UInteger )Aspect_VKeyMouse_LeftButton);
aMouseButtonMap.Bind ("middle", (Standard_UInteger )Aspect_VKeyMouse_MiddleButton);
aMouseButtonMap.Bind ("right", (Standard_UInteger )Aspect_VKeyMouse_RightButton);
}
Standard_UInteger aButton = (Standard_UInteger )Aspect_VKeyMouse_LeftButton;
AIS_MouseGesture aGesture = AIS_MouseGesture_RotateOrbit;
for (Standard_Integer anArgIter = 1; anArgIter < theArgsNb; ++anArgIter)
{
Standard_CString anArg = theArgVec[anArgIter];
TCollection_AsciiString anArgCase (anArg);
anArgCase.LowerCase();
if (anArgCase == "-button")
{
TCollection_AsciiString aButtonStr = theArgVec[++anArgIter];
aButtonStr.LowerCase();
aButton = aMouseButtonMap.Find1 (aButtonStr);
}
else if (anArgCase == "-gesture")
{
TCollection_AsciiString aGestureStr = theArgVec[++anArgIter];
aGestureStr.LowerCase();
aGesture = aGestureMap.Find1 (aGestureStr);
}
else
{
Message::SendFail() << "Error: unknown argument '" << anArg << "'";
return 1;
}
}
Handle(ViewerTest_EventManager) aViewMgr = ViewerTest::CurrentEventManager();
aViewMgr->ChangeMouseGestureMap().Bind (aButton, aGesture);
return 0;
}
//======================================================================= //=======================================================================
//function : ViewerTest_ExitProc //function : ViewerTest_ExitProc
//purpose : //purpose :
@@ -14994,12 +14927,4 @@ Turns on/off prebuilding of BVH within background thread(s).
-nbThreads number of threads, 1 by default; if < 1 then used (NbLogicalProcessors - 1); -nbThreads number of threads, 1 by default; if < 1 then used (NbLogicalProcessors - 1);
-wait waits for building all of BVH. -wait waits for building all of BVH.
)" /* [vselbvhbuild] */); )" /* [vselbvhbuild] */);
addCmd ("vchangemousegesture", VChangeMouseGesture, /* [vchangemousegesture] */ R"(
vchangemousegesture -button {none|left|middle|right}=left
-gesture {none|selectRectangle|selectLasso|zoom|zoomWindow|pan|rotateOrbit|rotateView|drag}=rotateOrbit
Changes the gesture for the mouse button.
-button the mouse button;
-gesture the new gesture for the button.
)" /* [vchangemousegesture] */);
} }

View File

@@ -92,8 +92,7 @@ TopoDS_Shape XSAlgo_AlgoContainer::ProcessShape(const TopoDS_Shape& theShape,
Handle(Standard_Transient)& theInfo, Handle(Standard_Transient)& theInfo,
const Handle(ShapeBuild_ReShape)& theReShape, const Handle(ShapeBuild_ReShape)& theReShape,
const Message_ProgressRange& theProgress, const Message_ProgressRange& theProgress,
const Standard_Boolean theNonManifold, const Standard_Boolean theNonManifold) const
const TopAbs_ShapeEnum theDetalisationLevel) const
{ {
if (theShape.IsNull()) if (theShape.IsNull())
{ {
@@ -115,7 +114,7 @@ TopoDS_Shape XSAlgo_AlgoContainer::ProcessShape(const TopoDS_Shape& theShape,
aRscfile = thePrscfile; aRscfile = thePrscfile;
aContext = new ShapeProcess_ShapeContext(theShape, aRscfile); aContext = new ShapeProcess_ShapeContext(theShape, aRscfile);
} }
aContext->SetDetalisation(theDetalisationLevel); aContext->SetDetalisation(TopAbs_EDGE);
} }
aContext->SetNonManifold(theNonManifold); aContext->SetNonManifold(theNonManifold);
theInfo = aContext; theInfo = aContext;
@@ -200,13 +199,12 @@ TopoDS_Shape XSAlgo_AlgoContainer::ProcessShape(const TopoDS_Shape& theShape,
const Standard_CString thePseq, const Standard_CString thePseq,
Handle(Standard_Transient)& theInfo, Handle(Standard_Transient)& theInfo,
const Message_ProgressRange& theProgress, const Message_ProgressRange& theProgress,
const Standard_Boolean theNonManifold, const Standard_Boolean theNonManifold) const
const TopAbs_ShapeEnum theDetalisationLevel) const
{ {
Handle(ShapeBuild_ReShape) aReShape = new ShapeBuild_ReShape(); Handle(ShapeBuild_ReShape) aReShape = new ShapeBuild_ReShape();
return ProcessShape(theShape, thePrec, theMaxTol, thePrscfile, return ProcessShape(theShape, thePrec, theMaxTol, thePrscfile,
thePseq, theInfo, aReShape, theProgress, thePseq, theInfo, aReShape, theProgress,
theNonManifold, theDetalisationLevel); theNonManifold);
} }
//======================================================================= //=======================================================================

View File

@@ -19,10 +19,9 @@
#include <Standard.hxx> #include <Standard.hxx>
#include <Standard_Type.hxx> #include <Standard_Type.hxx>
#include <Message_ProgressRange.hxx>
#include <Standard_Integer.hxx>
#include <Standard_Transient.hxx> #include <Standard_Transient.hxx>
#include <TopAbs_ShapeEnum.hxx> #include <Standard_Integer.hxx>
#include <Message_ProgressRange.hxx>
class ShapeBuild_ReShape; class ShapeBuild_ReShape;
class XSAlgo_ToolContainer; class XSAlgo_ToolContainer;
@@ -72,8 +71,7 @@ public:
const Standard_CString thePseq, const Standard_CString thePseq,
Handle(Standard_Transient)& theInfo, Handle(Standard_Transient)& theInfo,
const Message_ProgressRange& theProgress = Message_ProgressRange(), const Message_ProgressRange& theProgress = Message_ProgressRange(),
const Standard_Boolean theNonManifold = Standard_False, const Standard_Boolean theNonManifold = Standard_False) const;
const TopAbs_ShapeEnum theDetalisationLevel = TopAbs_VERTEX) const;
//! Does shape processing with specified tolerances //! Does shape processing with specified tolerances
//! @param[in] theShape shape to process //! @param[in] theShape shape to process
@@ -94,8 +92,7 @@ public:
Handle(Standard_Transient)& theInfo, Handle(Standard_Transient)& theInfo,
const Handle(ShapeBuild_ReShape)& theReShape, const Handle(ShapeBuild_ReShape)& theReShape,
const Message_ProgressRange& theProgress = Message_ProgressRange(), const Message_ProgressRange& theProgress = Message_ProgressRange(),
const Standard_Boolean theNonManifold = Standard_False, const Standard_Boolean theNonManifold = Standard_False) const;
const TopAbs_ShapeEnum theDetalisationLevel = TopAbs_VERTEX) const;
//! Checks quality of pcurve of the edge on the given face, //! Checks quality of pcurve of the edge on the given face,
//! and corrects it if necessary. //! and corrects it if necessary.

View File

@@ -1,10 +0,0 @@
puts "========================================="
puts "0033398: Modeling Algorithms - ShapeUpgrade_UnifySameDomain fails on specific STEP model"
puts "========================================="
puts ""
testreadstep [locate_data_file bug33398.step] s
unifysamedom result s
checknbshapes result -vertex 506 -edge 908 -wire 394 -face 382 -shell 4 -solid 4
checkview -display result -2d -path ${imagedir}/${test_image}.png

View File

@@ -1,19 +0,0 @@
puts "TODO CR33439 ALL: Error : is WRONG because number of EDGE entities in shape"
puts "TODO CR33439 ALL: Error : is WRONG because number of WIRE entities in shape"
puts "TODO CR33439 ALL: Error : is WRONG because number of FACE entities in shape"
puts "========================================="
puts "0033421: Modeling Algorithms - ShapeUpgrade_UnifySameDomain fails"
puts "========================================="
puts ""
pcylinder c1 10 10
copy c1 c2
tmirror c2 0 0 10 0 0 1
bop c1 c2
bopfuse c3
unifysamedom result c3
checknbshapes result -t -solid 1 -shell 1 -face 3 -wire 3 -edge 3 -vertex 3
checkview -display result -2d -path ${imagedir}/${test_image}.png

View File

@@ -1,14 +0,0 @@
puts "================================"
puts "0026578: Modeling Algorithm - Exceptions in offset operation with intersection"
puts "================================"
puts ""
restore [locate_data_file bug26578_plate1.brep] s
offsetparameter 1e-7 p i
offsetload s 100
offsetperform r
checkshape r
checknbshapes r -vertex 22 -edge 32 -wire 11 -face 11
checkview -display r -2d -path ${imagedir}/${test_image}.png

View File

@@ -1,12 +0,0 @@
puts "REQUIRED ALL: ERROR. Can not trim edges."
puts "================================"
puts "0026578: Modeling Algorithm - Exceptions in offset operation with intersection"
puts "================================"
puts ""
restore [locate_data_file bug26578_plate2.brep] s
offsetparameter 1e-7 p i
offsetload s -30
offsetperform r

View File

@@ -1,14 +0,0 @@
puts "================================"
puts "0026578: Modeling Algorithm - Exceptions in offset operation with intersection"
puts "================================"
puts ""
restore [locate_data_file bug26578_plate3.brep] s
offsetparameter 1e-7 p i
offsetload s 4
offsetperform r
checkshape r
checknbshapes r -vertex 25 -edge 36 -wire 12 -face 12
checkview -display r -2d -path ${imagedir}/${test_image}.png

View File

@@ -1,14 +0,0 @@
puts "================================"
puts "0026578: Modeling Algorithm - Exceptions in offset operation with intersection"
puts "================================"
puts ""
restore [locate_data_file bug26578_plate4.brep] s
offsetparameter 1e-7 p i
offsetload s 2
offsetperform r
checkshape r
checknbshapes r -vertex 22 -edge 31 -wire 10 -face 10
checkview -display r -2d -path ${imagedir}/${test_image}.png

View File

@@ -1,14 +0,0 @@
puts "================================"
puts "0026578: Modeling Algorithm - Exceptions in offset operation with intersection"
puts "================================"
puts ""
restore [locate_data_file bug26578_plate5.brep] s
offsetparameter 1e-7 p i
offsetload s 2
offsetperform r
checkshape r
checknbshapes r -vertex 39 -edge 57 -wire 19 -face 19
checkview -display r -2d -path ${imagedir}/${test_image}.png

View File

@@ -1,14 +0,0 @@
puts "================================"
puts "0026578: Modeling Algorithm - Exceptions in offset operation with intersection"
puts "================================"
puts ""
restore [locate_data_file bug26578_plate7.brep] s
offsetparameter 1e-7 p i
offsetload s 60
offsetperform r
checkshape r
checknbshapes r -vertex 15 -edge 21 -wire 7 -face 7
checkview -display r -2d -path ${imagedir}/${test_image}.png

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,27 +0,0 @@
puts "=================================="
puts "0032681: Data Exchange - Missed dimension after STEP export"
puts "Check adding of dimension"
puts "=================================="
pload DCAF
ReadStep D [locate_data_file bug32681.stp]
XGetOneShape s D
explode s V
XAddSubShape D s_1 0:1:1:1
XAddSubShape D s_84 0:1:1:1
XAddDimension D 0:1:1:1:57 0:1:1:1:58
param write.step.schema 5
param write.surfacecurve.mode 0
set tmpFile ${imagedir}/tmpFile.stp
WriteStep D $tmpFile
Close D
ReadStep D1 $tmpFile
set str [XDumpDGTs D1 all]
if {[string first "0:1:1:1:57" $str] == -1 || [string first "0:1:1:1:58" $str] == -1} {
puts "Error: don't find subshape"
}
Close D1
file delete $tmpFile
param write.step.schema 4
param write.surfacecurve.mode 1

View File

@@ -26,4 +26,3 @@
026 checkshape 026 checkshape
027 split_number 027 split_number
028 split_two_numbers 028 split_two_numbers
029 wire_fix_curves

View File

@@ -1,16 +0,0 @@
#############################################################
## Fix wire algo
## moves a curve of invalid wire to make it valid
#############################################################
circle c1 0 0 0 15
circle c2 0 0 0 15
trim c1 c1 0 pi
trim c2 c2 pi 2*pi
translate c1 0 0 0.00000005
translate c2 0 0 -0.00000005
mkedge c1 c1
mkedge c2 c2
strongwire w c1 c2
checkshape w
whatis w

View File

@@ -1,16 +0,0 @@
#############################################################
## Fix wire algo
## moves a curve of invalid wire to make it valid
#############################################################
ellipse e1 0 0 0 25 15
ellipse e2 0 0 0 25 15
trim e1 e1 0 pi
trim e2 e2 pi 2*pi
translate e1 0 0 0.00000005
translate e2 0 0 -0.00000005
mkedge e1 e1
mkedge e2 e2
strongwire w e1 e2
checkshape w
whatis w

View File

@@ -1,18 +0,0 @@
#############################################################
## Fix wire algo
## moves a curve of invalid wire to make it valid
#############################################################
point px 100 0 0
point py 0 100 0
point pz 0 0 100
vertex vx px
vertex vy py
edge exy vx vy
gcarc arc cir py pz px
mkedge earc arc
strongwire w exy earc
whatis w

View File

@@ -1,23 +0,0 @@
#############################################################
## Fix wire algo
## moves a curve of invalid wire to make it valid
#############################################################
point p1 0 0 0
point p2 100 0 0
point p4 100 110 0
gcarc arc cir p1 p2 p4
mkedge arc1 arc
mkedge arc2 arc
tmirror arc2 0 0 0 -110 100 0 -copy
ttranslate arc2 0 0 0.003 -copy
strongwire w1 arc1 arc2 -t 0.01 -m keepType
checkshape w1
whatis w1

View File

@@ -1,14 +0,0 @@
#############################################################
## Fix wire algo
## moves a curve of invalid wire to make it valid
#############################################################
bsplinecurve c1 3 2 -1.0 4 1.0 4 0 0 0 1 1 4 0 1 2 4 0 1 3 0 0 1
bsplinecurve c2 3 2 -1.0 4 1.0 4 0 0 0 1 1 -4 0 1 2 -4 0 1 3 0 0 1
translate c1 0 0 0.00000005
translate c2 0 0 -0.00000005
mkedge c1 c1
mkedge c2 c2
strongwire w c1 c2
checkshape w
whatis w

View File

@@ -1,17 +0,0 @@
#############################################################
## Fix wire algo
## moves a curve of invalid wire to make it valid
#############################################################
vertex v1 0 0 0
vertex v2 100 0 0
vertex v3 50 100 0
edge e1 v1 v2
edge e2 v2 v3
edge e3 v3 v1
strongwire w1 e1 e2 e3
checkshape w1
whatis w1

View File

@@ -1,7 +0,0 @@
restore [locate_data_file bug33420.brep] s
OFFSETSHAPE 35 {} $calcul $type
checkprops result -v 4.04602e+07
checknbshapes result -face 43 -shell 1

View File

@@ -1,5 +1,3 @@
puts "TODO OCC27414 ALL: Error : The area of result shape is"
restore [locate_data_file bug26917_M2_trim33.brep] s restore [locate_data_file bug26917_M2_trim33.brep] s
OFFSETSHAPE 8 {} $calcul $type OFFSETSHAPE 8 {} $calcul $type

View File

@@ -7,4 +7,4 @@ offsetperform result
checkprops result -s 6.21471e+06 -v 8.95633e+08 checkprops result -s 6.21471e+06 -v 8.95633e+08
unifysamedom result_unif result unifysamedom result_unif result
checknbshapes result_unif -wire 142 -face 140 -shell 1 -solid 1 checknbshapes result_unif -wire 140 -face 138 -shell 1 -solid 1

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)" }

View File

@@ -1,43 +0,0 @@
puts "=============================================="
puts "0032879: Visualization - Separate pan/zoom and move the object behavior in AIS_ViewController"
puts "=============================================="
puts ""
pload MODELING VISUALIZATION
vinit View1
pcylinder c1 5 10
vdisplay c1
vsetdispmode 1
vmanipulator m -attach c1 -adjustPosition 1 -adjustSize 0 -enableModes 1 -size 40
vfit
# note: mouse events cannot be emulated here, so the original bug cannot be reproduced by this test case
# pan for the left mouse button
vchangemousegesture -button left -gesture pan
set mouse_pick {204 194}
set mouse_drag {369 35}
vmoveto {*}$mouse_pick
vselect {*}$mouse_pick
vmanipulator m -startTransform {*}$mouse_pick
vmanipulator m -transform {*}$mouse_drag
vmanipulator m -stopTransform
vselect 0 0
vdump $imagedir/${casename}_pan.png
# zoom for the left mouse button
vchangemousegesture -button left -gesture zoom
set mouse_pick {206 32}
set mouse_drag {365 330}
vmoveto {*}$mouse_pick
vselect {*}$mouse_pick
vmanipulator m -startTransform {*}$mouse_pick
vmanipulator m -transform {*}$mouse_drag
vmanipulator m -stopTransform
vselect 0 0
vdump $imagedir/${casename}_zoom.png