X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FSierpinsky%2FSIERPINSKY_Gen_i.cxx;h=8894c399430fda72277e59752982448dbda41d19;hb=63f2641efb5b757eb441221703b7d79b97d7080c;hp=974d76c40d0b663e42f7afaf1f4f54bff8adc9d9;hpb=48f0d6ac1139268803ff4f590e34384e273e3ca0;p=samples%2Fsierpinsky.git diff --git a/src/Sierpinsky/SIERPINSKY_Gen_i.cxx b/src/Sierpinsky/SIERPINSKY_Gen_i.cxx index 974d76c..8894c39 100644 --- a/src/Sierpinsky/SIERPINSKY_Gen_i.cxx +++ b/src/Sierpinsky/SIERPINSKY_Gen_i.cxx @@ -1,26 +1,46 @@ +// Copyright (C) 2005-2024 OPEN CASCADE +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + /////////////////////////////////////////////////////////// // File : SIERPINSKY_Gen_i.cxx // Author : Vadim SANDLER (OCN) // Created : 13/07/05 -// Copyright (C) 2005 Open CASCADE /////////////////////////////////////////////////////////// #include "SIERPINSKY_Gen_i.hxx" +#include "SIERPINSKY_version.h" #include +#ifdef WITH_LIBGD #include - -using namespace MED; +#endif // WITH_LIBGD /*! * Engine factory */ extern "C" -{ +{ + SIERPINSKYENGINE_EXPORT PortableServer::ObjectId * SIERPINSKYEngine_factory( CORBA::ORB_ptr orb, - PortableServer::POA_ptr poa, - PortableServer::ObjectId* contId, - const char* instanceName, - const char* interfaceName ) + PortableServer::POA_ptr poa, + PortableServer::ObjectId* contId, + const char* instanceName, + const char* interfaceName ) { SIERPINSKY_Gen_i* anEngine = new SIERPINSKY_Gen_i( orb, poa, contId, instanceName, interfaceName ); return anEngine->getId() ; @@ -38,10 +58,10 @@ SIERPINSKY_Gen_i::SIERPINSKY_Gen_i() * Constructor */ SIERPINSKY_Gen_i::SIERPINSKY_Gen_i( CORBA::ORB_ptr orb, - PortableServer::POA_ptr poa, - PortableServer::ObjectId* contId, - const char* instanceName, - const char* interfaceName ) + PortableServer::POA_ptr poa, + PortableServer::ObjectId* contId, + const char* instanceName, + const char* interfaceName ) : Engines_Component_i( orb, poa, contId, instanceName, interfaceName ) { // activate servant @@ -63,8 +83,8 @@ SIERPINSKY_Gen_i::~SIERPINSKY_Gen_i() * Initializes engine with three reference points */ void SIERPINSKY_Gen_i::Init( CORBA::Double theX1, CORBA::Double theY1, - CORBA::Double theX2, CORBA::Double theY2, - CORBA::Double theX3, CORBA::Double theY3 ) + CORBA::Double theX2, CORBA::Double theY2, + CORBA::Double theX3, CORBA::Double theY3 ) { myRefPoints[0] = MyPoint( theX1, theY1 ); myRefPoints[1] = MyPoint( theX2, theY2 ); @@ -87,8 +107,8 @@ void SIERPINSKY_Gen_i::Reset() * Generates next iteration point */ void SIERPINSKY_Gen_i::NextPoint( CORBA::Double theX, CORBA::Double theY, - CORBA::Long theIter, - CORBA::Double& theNextX, CORBA::Double& theNextY ) + CORBA::Long theIter, + CORBA::Double& theNextX, CORBA::Double& theNextY ) { double x = theIter < 1 || theIter > 3 ? theX : ( theX + myRefPoints[ theIter-1 ].myX ) / 2; double y = theIter < 1 || theIter > 3 ? theY : ( theY + myRefPoints[ theIter-1 ].myY ) / 2; @@ -102,6 +122,7 @@ void SIERPINSKY_Gen_i::NextPoint( CORBA::Double theX, CORBA::Double theY, */ CORBA::Boolean SIERPINSKY_Gen_i::ExportToJPEG( const char* theFileName, CORBA::Long theSize ) { +#ifdef WITH_LIBGD if ( theSize <= 0 ) return false; // open file @@ -127,6 +148,10 @@ CORBA::Boolean SIERPINSKY_Gen_i::ExportToJPEG( const char* theFileName, CORBA::L gdImageDestroy( image ); return true; +#else // WITH_LIBGD + printf("Warning: ExportToJPEG() is not supported (libgd is required)!"); + return false; +#endif // WITH_LIBGD } /*! @@ -134,7 +159,7 @@ CORBA::Boolean SIERPINSKY_Gen_i::ExportToJPEG( const char* theFileName, CORBA::L */ CORBA::Boolean SIERPINSKY_Gen_i::ExportToMED( const char* theFileName, CORBA::Double theSize ) { - TErr anError; + MED::TErr anError; // if file already exists - remove it (MED cannot overwrite files correctly) FILE* aFile = fopen( theFileName, "rb" ); @@ -144,16 +169,16 @@ CORBA::Boolean SIERPINSKY_Gen_i::ExportToMED( const char* theFileName, CORBA::Do } // create MED 2.2 file - PWrapper aMed = CrWrapper( theFileName, MED::eV2_2 ); + MED::PWrapper aMed = MED::CrWrapperW( theFileName ); // create 2D mesh - PMeshInfo aMesh = aMed->CrMeshInfo( 2, "Sierpinsky" ); + MED::PMeshInfo aMesh = aMed->CrMeshInfo( 2, 2, "Sierpinsky" ); aMed->SetMeshInfo( aMesh, &anError ); if ( anError < 0 ) return false; // create nodes - TFloatVector nodes; - TIntVector connect; + MED::TFloatVector nodes; + MED::TIntVector connect; std::list::const_iterator iter; int ind = 1; for ( iter = myPoints.begin(); iter != myPoints.end(); ++iter ) { @@ -161,13 +186,31 @@ CORBA::Boolean SIERPINSKY_Gen_i::ExportToMED( const char* theFileName, CORBA::Do nodes.push_back( (*iter).myY * theSize ); connect.push_back( ind++ ); } - PNodeInfo aNodes = aMed->CrNodeInfo( aMesh, nodes, MED::eFULL_INTERLACE, MED::eCART, TStringVector(2), TStringVector(2), TIntVector( myPoints.size() ), TIntVector() ); + MED::PNodeInfo aNodes = aMed->CrNodeInfo( aMesh, nodes, + MED::eFULL_INTERLACE, MED::eCART, + MED::TStringVector(2), + MED::TStringVector(2), + MED::TIntVector( myPoints.size() ), + MED::TIntVector() ); aMed->SetNodeInfo( aNodes, &anError ); if ( anError < 0 ) return false; - PCellInfo aCells = aMed->CrCellInfo( aMesh, MED::eMAILLE, MED::ePOINT1, connect, eNOD, TIntVector( myPoints.size() ), TIntVector( myPoints.size() ) ); + MED::PCellInfo aCells = aMed->CrCellInfo( aMesh, MED::eMAILLE, MED::ePOINT1, + connect, MED::eNOD, + MED::TIntVector( myPoints.size() ), + MED::TIntVector( myPoints.size() ) ); aMed->SetCellInfo( aCells, &anError ); if ( anError < 0 ) return false; return true; } + +// Version information +char* SIERPINSKY_Gen_i::getVersion() +{ +#if SIERPINSKY_DEVELOPMENT + return CORBA::string_dup(SIERPINSKY_VERSION_STR"dev"); +#else + return CORBA::string_dup(SIERPINSKY_VERSION_STR); +#endif +}