-// Copyright (C) 2005-2012 OPEN CASCADE
+// Copyright (C) 2005-2023 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.
+// 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
// Author : Vadim SANDLER (OCN)
// Created : 13/07/05
///////////////////////////////////////////////////////////
-//
#include "SIERPINSKY_Gen_i.hxx"
#include "SIERPINSKY_version.h"
#include <MED_Factory.hxx>
+#ifdef WITH_LIBGD
#include <gd.h>
-
-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() ;
* 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
* 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 );
* 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;
*/
CORBA::Boolean SIERPINSKY_Gen_i::ExportToJPEG( const char* theFileName, CORBA::Long theSize )
{
+#ifdef WITH_LIBGD
if ( theSize <= 0 ) return false;
// open file
gdImageDestroy( image );
return true;
+#else // WITH_LIBGD
+ printf("Warning: ExportToJPEG() is not supported (libgd is required)!");
+ return false;
+#endif // WITH_LIBGD
}
/*!
*/
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" );
}
// 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, 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<MyPoint>::const_iterator iter;
int ind = 1;
for ( iter = myPoints.begin(); iter != myPoints.end(); ++iter ) {
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;