1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-16 10:08:36 +03:00

0024252: GCC warnings on breakage of strict-aliasing rules

Fixed type casts in NCollection maps
Avoid invalid type cast in handling of LDOM text object
Use correct pointer type in callback function of Graphic3d_CGraduatedTrihedron class
Format of printf() simplified in IntPatch_Point.cxx
This commit is contained in:
abv 2014-01-15 06:40:18 +04:00 committed by bugmaster
parent 504a896866
commit fd03ee4b3b
10 changed files with 49 additions and 113 deletions

View File

@ -24,10 +24,13 @@
#include <TCollection_ExtendedString.hxx> #include <TCollection_ExtendedString.hxx>
#include <Font_FontAspect.hxx> #include <Font_FontAspect.hxx>
typedef void (*minMaxValuesCallback)(void*); class Visual3d_View;
class Graphic3d_CGraduatedTrihedron class Graphic3d_CGraduatedTrihedron
{ {
public: public:
typedef void (*minMaxValuesCallback)(Visual3d_View*);
public:
/* Default constructor. Nullifies the view pointer */ /* Default constructor. Nullifies the view pointer */
Graphic3d_CGraduatedTrihedron () : xdrawname ( Standard_False ), Graphic3d_CGraduatedTrihedron () : xdrawname ( Standard_False ),
ydrawname ( Standard_False ), ydrawname ( Standard_False ),
@ -95,7 +98,7 @@ class Graphic3d_CGraduatedTrihedron
/* Callback function to define boundary box of displayed objects */ /* Callback function to define boundary box of displayed objects */
minMaxValuesCallback cbCubicAxes; minMaxValuesCallback cbCubicAxes;
void* ptrVisual3dView; Visual3d_View* ptrVisual3dView;
}; };
const Handle(Standard_Type)& TYPE(Graphic3d_CGraduatedTrihedron); const Handle(Standard_Type)& TYPE(Graphic3d_CGraduatedTrihedron);

View File

@ -148,61 +148,26 @@ void IntPatch_Point::Dump() const {
cout<<"----------- IntPatch_Point : "<<endl; cout<<"----------- IntPatch_Point : "<<endl;
Standard_Real u1,v1,u2,v2; Standard_Real u1,v1,u2,v2;
pt.Parameters(u1,v1,u2,v2); pt.Parameters(u1,v1,u2,v2);
#if 0
cout<<"IntSurf_PntOn2S : Pnt ("<<pt.Value().X()
<<","<<pt.Value().Y()<<","<<pt.Value().Z()<<")"<<endl;
cout<<" u1:"<<u1; cout<<" u2:"<<u2;
cout<<" v1:"<<v1;
cout<<" v2:"<<v2<<endl;
cout<<" para("<<para<<")";
cout<<" mult("<<mult<<")";
cout<<" OnS1("<<onS1<<")";
cout<<" VtxOnS1("<<vtxonS1<<")"<<endl;
cout<<" OnS2("<<onS2<<")";
cout<<" VtxOnS2("<<vtxonS2<<")";
cout<<" prm1("<<prm1<<")";
cout<<" prm2("<<prm2<<")";
#else
#ifndef DEB // for porting on linux
printf("P(%15.10f,%15.10f,%15.10f) UV1(%15.10f,%15.10f) UV2(%15.10f,%15.10f) (Para:%15.10f)\n", printf("P(%15.10f,%15.10f,%15.10f) UV1(%15.10f,%15.10f) UV2(%15.10f,%15.10f) (Para:%15.10f)\n",
(double)(pt.Value().X()), (double)(pt.Value().X()),
(double)(pt.Value().Y()), (double)(pt.Value().Y()),
(double)(pt.Value().Z()), (double)(pt.Value().Z()),
(double)u1,(double)v1,(double)u2,(double)v2,(double)para); (double)u1,(double)v1,(double)u2,(double)v2,(double)para);
if(onS1) { printf("*OnS1* par=%15.10f arc1=%10lu",(double)prm1, if(onS1)
*((long unsigned *)(((Handle_Standard_Transient *)(&arcS1)))) printf("*OnS1* par=%15.10f arc1=%10p", (double)prm1, (void*)arcS1.operator->());
); } if(vtxonS1)
if(vtxonS1) { printf(" *Vtx1* vtx1=%10lu", printf(" *Vtx1* vtx1=%10p", (void*)vS1.operator->());
*((long unsigned *)(((Handle_Standard_Transient *)(&vS1))))); }
if(onS1 || vtxonS1) printf("\n"); if(onS1 || vtxonS1) printf("\n");
if(onS2) { printf("*OnS2* par=%15.10f arc2=%10lu",(double)prm2, if(onS2)
*((long unsigned *)(((Handle_Standard_Transient *)(&arcS2))))); } printf("*OnS2* par=%15.10f arc2=%10p", (double)prm2, (void*)arcS2.operator->());
if(vtxonS2) { printf(" *Vtx2* vtx2=%10lu", if(vtxonS2)
*((long unsigned *)(((Handle_Standard_Transient *)(&vS2))))); } printf(" *Vtx2* vtx2=%10lu", (void*)vS2.operator->());
#else // debug mode if(onS2 || vtxonS2)
printf("P(%15.10lf,%15.10lf,%15.10lf) UV1(%15.10lf,%15.10lf) UV2(%15.10lf,%15.10lf) (Para:%15.10lf)\n", printf("\n");
(double)(pt.Value().X()),
(double)(pt.Value().Y()),
(double)(pt.Value().Z()),
(double)u1,(double)v1,(double)u2,(double)v2,(double)para);
if(onS1) { printf("*OnS1* par=%15.10lf arc1=%10lu",(double)prm1,
*((long unsigned *)(((Handle_Standard_Transient *)(&arcS1))))
); }
if(vtxonS1) { printf(" *Vtx1* vtx1=%10lu",
*((long unsigned *)(((Handle_Standard_Transient *)(&vS1))))); }
if(onS1 || vtxonS1) printf("\n");
if(onS2) { printf("*OnS2* par=%15.10lf arc2=%10lu",(double)prm2,
*((long unsigned *)(((Handle_Standard_Transient *)(&arcS2))))); }
if(vtxonS2) { printf(" *Vtx2* vtx2=%10lu",
*((long unsigned *)(((Handle_Standard_Transient *)(&vS2))))); }
#endif
if(onS2 || vtxonS2) printf("\n");
fflush(stdout); fflush(stdout);
#endif
if(onS1 || onS2) { if(onS1 || onS2) {
cout<<" tgt:"<<((tgt)? 1 : 0) <<" mult:"<<((mult)? 1 :0); cout<<" tgt:"<<((tgt)? 1 : 0) <<" mult:"<<((mult)? 1 :0);
if(onS1) { if(onS1) {

View File

@ -173,13 +173,10 @@ template < class TheKeyType,
//! ReSize //! ReSize
void ReSize (const Standard_Integer N) void ReSize (const Standard_Integer N)
{ {
DataMapNode** newdata = NULL; NCollection_ListNode** newdata = NULL;
DataMapNode** dummy = NULL; NCollection_ListNode** dummy = NULL;
Standard_Integer newBuck; Standard_Integer newBuck;
if (BeginResize (N, newBuck, if (BeginResize (N, newBuck, newdata, dummy, this->myAllocator))
(NCollection_ListNode**&)newdata,
(NCollection_ListNode**&)dummy,
this->myAllocator))
{ {
if (myData1) if (myData1)
{ {
@ -202,10 +199,7 @@ template < class TheKeyType,
} }
} }
} }
EndResize(N,newBuck, EndResize (N, newBuck, newdata, dummy, this->myAllocator);
(NCollection_ListNode**&)newdata,
(NCollection_ListNode**&)dummy,
this->myAllocator);
} }
} }

View File

@ -193,13 +193,10 @@ template < class TheKey1Type,
//! ReSize //! ReSize
void ReSize (const Standard_Integer N) void ReSize (const Standard_Integer N)
{ {
DoubleMapNode** ppNewData1 = NULL; NCollection_ListNode** ppNewData1 = NULL;
DoubleMapNode** ppNewData2 = NULL; NCollection_ListNode** ppNewData2 = NULL;
Standard_Integer newBuck; Standard_Integer newBuck;
if (BeginResize (N, newBuck, if (BeginResize (N, newBuck, ppNewData1, ppNewData2, this->myAllocator))
(NCollection_ListNode**&)ppNewData1,
(NCollection_ListNode**&)ppNewData2,
this->myAllocator))
{ {
if (myData1) if (myData1)
{ {
@ -216,7 +213,7 @@ template < class TheKey1Type,
iK2 = Hasher2::HashCode (p->Key2(), newBuck); iK2 = Hasher2::HashCode (p->Key2(), newBuck);
q = (DoubleMapNode*) p->Next(); q = (DoubleMapNode*) p->Next();
p->Next() = ppNewData1[iK1]; p->Next() = ppNewData1[iK1];
p->Next2() = ppNewData2[iK2]; p->Next2() = (DoubleMapNode*)ppNewData2[iK2];
ppNewData1[iK1] = p; ppNewData1[iK1] = p;
ppNewData2[iK2] = p; ppNewData2[iK2] = p;
p = q; p = q;
@ -224,10 +221,7 @@ template < class TheKey1Type,
} }
} }
} }
EndResize(N,newBuck, EndResize (N, newBuck, ppNewData1, ppNewData2, this->myAllocator);
(NCollection_ListNode**&)ppNewData1,
(NCollection_ListNode**&)ppNewData2,
this->myAllocator);
} }
} }

View File

@ -197,13 +197,10 @@ template < class TheKeyType,
//! ReSize //! ReSize
void ReSize (const Standard_Integer N) void ReSize (const Standard_Integer N)
{ {
IndexedDataMapNode** ppNewData1 = NULL; NCollection_ListNode** ppNewData1 = NULL;
IndexedDataMapNode** ppNewData2 = NULL; NCollection_ListNode** ppNewData2 = NULL;
Standard_Integer newBuck; Standard_Integer newBuck;
if (BeginResize (N, newBuck, if (BeginResize (N, newBuck, ppNewData1, ppNewData2, this->myAllocator))
(NCollection_ListNode**&)ppNewData1,
(NCollection_ListNode**&)ppNewData2,
this->myAllocator))
{ {
if (myData1) if (myData1)
{ {
@ -220,7 +217,7 @@ template < class TheKeyType,
iK2 = ::HashCode (p->Key2(), newBuck); iK2 = ::HashCode (p->Key2(), newBuck);
q = (IndexedDataMapNode*) p->Next(); q = (IndexedDataMapNode*) p->Next();
p->Next() = ppNewData1[iK1]; p->Next() = ppNewData1[iK1];
p->Next2() = ppNewData2[iK2]; p->Next2() = (IndexedDataMapNode*)ppNewData2[iK2];
ppNewData1[iK1] = p; ppNewData1[iK1] = p;
ppNewData2[iK2] = p; ppNewData2[iK2] = p;
p = q; p = q;
@ -228,10 +225,7 @@ template < class TheKeyType,
} }
} }
} }
EndResize(N,newBuck, EndResize (N, newBuck, ppNewData1, ppNewData2, this->myAllocator);
(NCollection_ListNode**&)ppNewData1,
(NCollection_ListNode**&)ppNewData2,
this->myAllocator);
} }
} }

View File

@ -187,13 +187,10 @@ template < class TheKeyType,
//! ReSize //! ReSize
void ReSize (const Standard_Integer N) void ReSize (const Standard_Integer N)
{ {
IndexedMapNode** ppNewData1 = NULL; NCollection_ListNode** ppNewData1 = NULL;
IndexedMapNode** ppNewData2 = NULL; NCollection_ListNode** ppNewData2 = NULL;
Standard_Integer newBuck; Standard_Integer newBuck;
if (BeginResize (N, newBuck, if (BeginResize (N, newBuck, ppNewData1, ppNewData2, this->myAllocator))
(NCollection_ListNode**&)ppNewData1,
(NCollection_ListNode**&)ppNewData2,
this->myAllocator))
{ {
if (myData1) if (myData1)
{ {
@ -213,7 +210,7 @@ template < class TheKeyType,
if (p->Key2() > 0) if (p->Key2() > 0)
{ {
iK2 = ::HashCode (p->Key2(), newBuck); iK2 = ::HashCode (p->Key2(), newBuck);
p->Next2() = ppNewData2[iK2]; p->Next2() = (IndexedMapNode*)ppNewData2[iK2];
ppNewData2[iK2] = p; ppNewData2[iK2] = p;
} }
p = q; p = q;
@ -221,10 +218,7 @@ template < class TheKeyType,
} }
} }
} }
EndResize(N,newBuck, EndResize (N, newBuck, ppNewData1, ppNewData2, this->myAllocator);
(NCollection_ListNode**&)ppNewData1,
(NCollection_ListNode**&)ppNewData2,
this->myAllocator);
} }
} }

View File

@ -177,13 +177,10 @@ template < class TheKeyType,
//! ReSize //! ReSize
void ReSize (const Standard_Integer N) void ReSize (const Standard_Integer N)
{ {
MapNode** newdata = 0L; NCollection_ListNode** newdata = 0L;
MapNode** dummy = 0L; NCollection_ListNode** dummy = 0L;
Standard_Integer newBuck; Standard_Integer newBuck;
if (BeginResize (N, newBuck, if (BeginResize (N, newBuck, newdata, dummy, this->myAllocator))
(NCollection_ListNode**&)newdata,
(NCollection_ListNode**&)dummy,
this->myAllocator))
{ {
if (myData1) if (myData1)
{ {
@ -206,10 +203,7 @@ template < class TheKeyType,
} }
} }
} }
EndResize(N,newBuck, EndResize (N, newBuck, newdata, dummy, this->myAllocator);
(NCollection_ListNode**&)newdata,
(NCollection_ListNode**&)dummy,
this->myAllocator);
} }
} }

View File

@ -21,6 +21,7 @@
#include <OpenGl_Text.hxx> #include <OpenGl_Text.hxx>
#include <Graphic3d_CGraduatedTrihedron.hxx> #include <Graphic3d_CGraduatedTrihedron.hxx>
class Visual3d_View;
class OpenGl_View; class OpenGl_View;
class OpenGl_GraduatedTrihedron : public OpenGl_Element class OpenGl_GraduatedTrihedron : public OpenGl_Element
@ -73,8 +74,8 @@ protected:
TEL_COLOUR myXColor; TEL_COLOUR myXColor;
TEL_COLOUR myYColor; TEL_COLOUR myYColor;
TEL_COLOUR myZColor; TEL_COLOUR myZColor;
minMaxValuesCallback myCbCubicAxes; Graphic3d_CGraduatedTrihedron::minMaxValuesCallback myCbCubicAxes;
void* myPtrVisual3dView; Visual3d_View* myPtrVisual3dView;
public: public:

View File

@ -3021,22 +3021,20 @@ void Visual3d_View::TriedronEcho (const Aspect_TypeOfTriedronEcho AType ) {
} }
Standard_Boolean checkFloat(const Standard_Real value) static Standard_Boolean checkFloat(const Standard_Real value)
{ {
return value > -FLT_MAX && value < FLT_MAX; return value > -FLT_MAX && value < FLT_MAX;
} }
void SetMinMaxValuesCallback(void* Visual3dView) static void SetMinMaxValuesCallback(Visual3d_View* theView)
{ {
Standard_Real xmin, ymin, zmin, xmax, ymax, zmax; Standard_Real xmin, ymin, zmin, xmax, ymax, zmax;
theView->MinMaxValues(xmin, ymin, zmin, xmax, ymax, zmax);
Handle(Visual3d_View) view = (Handle(Visual3d_View)&) Visual3dView;
view->MinMaxValues(xmin, ymin, zmin, xmax, ymax, zmax);
if (checkFloat(xmin) && checkFloat(ymin) && checkFloat(zmin) && if (checkFloat(xmin) && checkFloat(ymin) && checkFloat(zmin) &&
checkFloat(xmax) && checkFloat(ymax) && checkFloat(zmax)) checkFloat(xmax) && checkFloat(ymax) && checkFloat(zmax))
{ {
Handle(Graphic3d_GraphicDriver) driver = Handle(Graphic3d_GraphicDriver)::DownCast(view->GraphicDriver()); Handle(Graphic3d_GraphicDriver) driver = Handle(Graphic3d_GraphicDriver)::DownCast(theView->GraphicDriver());
driver->GraduatedTrihedronMinMaxValues((Standard_ShortReal)xmin, (Standard_ShortReal)ymin, (Standard_ShortReal)zmin, driver->GraduatedTrihedronMinMaxValues((Standard_ShortReal)xmin, (Standard_ShortReal)ymin, (Standard_ShortReal)zmin,
(Standard_ShortReal)xmax, (Standard_ShortReal)ymax, (Standard_ShortReal)zmax); (Standard_ShortReal)xmax, (Standard_ShortReal)ymax, (Standard_ShortReal)zmax);
} }

View File

@ -344,8 +344,7 @@ void XmlMNaming_NamedShapeDriver::ReadShapeSection
aNode = anElement.getNextSibling()) aNode = anElement.getNextSibling())
{ {
if (aNode.getNodeType() == LDOM_Node::TEXT_NODE) { if (aNode.getNodeType() == LDOM_Node::TEXT_NODE) {
LDOM_Text aText = (LDOM_Text&) aNode; LDOMString aData = aNode.getNodeValue();
LDOMString aData = aText.getData();
#ifdef USE_STL_STREAM #ifdef USE_STL_STREAM
std::stringstream aStream (std::string(aData.GetString())); std::stringstream aStream (std::string(aData.GetString()));
#else #else