SALOME PAL V1_4_1

This commit is contained in:
smh 2004-04-05 14:29:26 +00:00
parent 0b9bd142d3
commit 143d55f45f
131 changed files with 20995 additions and 0 deletions

110
idl/SMESH_Filter.idl Normal file
View File

@ -0,0 +1,110 @@
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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.
//
// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : SMESH_Filter.idl
// Author : Alexey Petrov, OCC
#ifndef _SMESH_FILTER_IDL_
#define _SMESH_FILTER_IDL_
#include "SALOME_Exception.idl"
#include "SALOME_GenericObj.idl"
#include "SMESH_Mesh.idl"
module SMESH{
interface Functor: SALOME::GenericObj{
void SetMesh(in SMESH_Mesh theMesh);
};
interface NumericalFunctor: Functor{
double GetValue(in long theElementId);
};
interface MinimumAngle: NumericalFunctor{};
interface AspectRatio: NumericalFunctor{};
interface Warping: NumericalFunctor{};
interface Taper: NumericalFunctor{};
interface Skew: NumericalFunctor{};
interface Area: NumericalFunctor{};
interface Length: NumericalFunctor{};
interface MultiConnection: NumericalFunctor{};
interface Predicate: Functor{
boolean IsSatisfy(in long thEntityId);
};
interface FreeBorders: Predicate{};
interface Comparator: Predicate{
void SetMargin(in double theValue);
void SetNumFunctor(in NumericalFunctor theFunct);
};
interface LessThan: Comparator{};
interface MoreThan: Comparator{};
interface EqualTo: Comparator{
void SetTolerance(in double theTolerance );
};
interface Logical: Predicate{};
interface LogicalNOT: Logical{
void SetPredicate(in Predicate thePredicate);
};
interface LogicalBinary: Logical{
void SetPredicate1(in Predicate thePredicate);
void SetPredicate2(in Predicate thePredicate);
};
interface LogicalAND: LogicalBinary{};
interface LogicalOR: LogicalBinary{};
interface Filter: SALOME::GenericObj{
void SetPredicate( in Predicate thePredicate );
long_array GetElementsId( in SMESH_Mesh theMesh );
};
interface FilterManager: SALOME::GenericObj{
MinimumAngle CreateMinimumAngle();
AspectRatio CreateAspectRatio();
Warping CreateWarping();
Taper CreateTaper();
Skew CreateSkew();
Area CreateArea();
Length CreateLength();
MultiConnection CreateMultiConnection();
FreeBorders CreateFreeBorders();
LessThan CreateLessThan();
MoreThan CreateMoreThan();
EqualTo CreateEqualTo();
LogicalNOT CreateLogicalNOT();
LogicalAND CreateLogicalAND();
LogicalOR CreateLogicalOR();
Filter CreateFilter();
};
};
#endif

103
idl/SMESH_Group.idl Normal file
View File

@ -0,0 +1,103 @@
// Copyright (C) 2004 CEA
//
// 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.
//
// 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.org
//
//
//
// File : SMESH_Group.idl
// Author : Sergey ANIKIN, OCC
// $Header$
#ifndef _SMESH_GROUP_IDL_
#define _SMESH_GROUP_IDL_
#include "SALOME_Exception.idl"
#include "SALOME_GenericObj.idl"
#include "SMESH_Mesh.idl"
module SMESH
{
/*!
* SMESH_Group: interface of group object
*/
interface SMESH_Group : SALOME::GenericObj
{
/*!
* Sets group name
*/
void SetName( in string name );
/*!
* Returns group name
*/
string GetName();
/*!
* Returns group type (type of elements in the group)
*/
ElementType GetType();
/*!
* Returns the number of elements in the group
*/
long Size();
/*!
* Returns true if the group does not contain any elements
*/
boolean IsEmpty();
/*!
* Clears the group's contents
*/
void Clear();
/*!
* returns true if the group contains an element with ID == <elem_id>
*/
boolean Contains( in long elem_id );
/*!
* Adds elements to the group
*/
long Add( in long_array elem_ids );
/*!
* Returns ID of an element at position <elem_index>
*/
long GetID( in long elem_index );
/*!
* Returns a sequence of all element IDs in the group
*/
long_array GetListOfID();
/*!
* Removes elements from the group
*/
long Remove( in long_array elem_ids );
/*!
* Returns the mesh object this group belongs to
*/
SMESH_Mesh GetMesh();
};
};
#endif

View File

@ -0,0 +1,45 @@
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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.
//
// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : SMESH_NetgenAlgorithm.idl
// Author : Julia DOROVSKIKH
// $Header$
#ifndef _SMESH_NETGENALGORITHM_IDL_
#define _SMESH_NETGENALGORITHM_IDL_
#include "SMESH_Hypothesis.idl"
/*!
* NETGENPlugin: interfaces to NETGEN related hypotheses and algorithms
*/
module NETGENPlugin
{
/*!
* NETGENPlugin_NETGEN_3D: interface of "Tetrahedron (Netgen)" algorithm
*/
interface NETGENPlugin_NETGEN_3D : SMESH::SMESH_3D_Algo
{
};
};
#endif

2
resources/SMESH.config Normal file
View File

@ -0,0 +1,2 @@
language=en
resources=StdMeshers:NETGENPlugin

View File

@ -0,0 +1,78 @@
<?xml version='1.0' encoding='us-ascii'?>
<!DOCTYPE meshers PUBLIC "" "desktop.dtd">
<!-- GUI customization for MESH component -->
<meshers>
<meshers-group name="Standard Meshers"
resources="StdMeshers"
server-lib="libStdMeshersEngine.so"
gui-lib="libStdMeshersGUI.so">
<hypotheses>
<hypothesis type="LocalLength"
label-id="Average length"
icon-id="mesh_hypo_length.png"/>
<hypothesis type="LengthFromEdges"
label-id="Length From Edges (2D Hyp. for Triangulator)"
icon-id="mesh_hypo_length.png"/>
<hypothesis type="NumberOfSegments"
label-id="Nb. Segments"
icon-id="mesh_hypo_segment.png"/>
<hypothesis type="MaxElementArea"
label-id="Max. Triangle Area"
icon-id="mesh_hypo_area.png"/>
<hypothesis type="MaxElementVolume"
label-id="Max. Hexahedron or Tetrahedron Volume"
icon-id="mesh_hypo_volume.png"/>
<hypothesis type="NotConformAllowed"
label-id="Not Conform Mesh Allowed"
icon-id="mesh_hypo_length.png"/>
</hypotheses>
<algorithms>
<algorithm type="Regular_1D"
label-id="Wire discretisation"
icon-id="mesh_algo_regular.png"/>
<algorithm type="MEFISTO_2D"
label-id="Triangle (Mefisto)"
icon-id="mesh_algo_mefisto.png"/>
<algorithm type="Quadrangle_2D"
label-id="Quadrangle (Mapping)"
icon-id="mesh_algo_quad.png"/>
<algorithm type="Hexa_3D"
label-id="Hexahedron (i,j,k)"
icon-id="mesh_algo_hexa.png"/>
</algorithms>
</meshers-group>
<meshers-group name="Your Meshers Group"
resources=""
server-lib=""
gui-lib="">
<hypotheses>
<hypothesis type=""
label-id=""
icon-id=""/>
</hypotheses>
<algorithms>
<algorithm type=""
label-id=""
icon-id=""/>
</algorithms>
</meshers-group>
</meshers>

View File

@ -0,0 +1,89 @@
<?xml version='1.0' encoding='us-ascii'?>
<!DOCTYPE meshers PUBLIC "" "desktop.dtd">
<!-- GUI customization for MESH component -->
<meshers>
<meshers-group name="Standard Meshers"
resources="StdMeshers"
server-lib="libStdMeshersEngine.so"
gui-lib="libStdMeshersGUI.so">
<hypotheses>
<hypothesis type="LocalLength"
label-id="Average length"
icon-id="mesh_hypo_length.png"/>
<hypothesis type="LengthFromEdges"
label-id="Length From Edges (2D Hyp. for Triangulator)"
icon-id="mesh_hypo_length.png"/>
<hypothesis type="NumberOfSegments"
label-id="Nb. Segments"
icon-id="mesh_hypo_segment.png"/>
<hypothesis type="MaxElementArea"
label-id="Max. Triangle Area"
icon-id="mesh_hypo_area.png"/>
<hypothesis type="MaxElementVolume"
label-id="Max. Hexahedron or Tetrahedron Volume"
icon-id="mesh_hypo_volume.png"/>
<hypothesis type="NotConformAllowed"
label-id="Not Conform Mesh Allowed"
icon-id="mesh_hypo_length.png"/>
</hypotheses>
<algorithms>
<algorithm type="Regular_1D"
label-id="Wire discretisation"
icon-id="mesh_algo_regular.png"/>
<algorithm type="MEFISTO_2D"
label-id="Triangle (Mefisto)"
icon-id="mesh_algo_mefisto.png"/>
<algorithm type="Quadrangle_2D"
label-id="Quadrangle (Mapping)"
icon-id="mesh_algo_quad.png"/>
<algorithm type="Hexa_3D"
label-id="Hexahedron (i,j,k)"
icon-id="mesh_algo_hexa.png"/>
</algorithms>
</meshers-group>
<meshers-group name="NETGEN"
resources="NETGENPlugin"
server-lib="libNETGENEngine.so"
gui-lib="">
<algorithms>
<algorithm type="NETGEN_3D"
label-id="Tetrahedron (Netgen)"
icon-id="mesh_algo_tetra.png"/>
</algorithms>
</meshers-group>
<meshers-group name="Your Meshers Group"
resources=""
server-lib=""
gui-lib="">
<hypotheses>
<hypothesis type=""
label-id=""
icon-id=""/>
</hypotheses>
<algorithms>
<algorithm type=""
label-id=""
icon-id=""/>
</algorithms>
</meshers-group>
</meshers>

78
resources/StdMeshers.xml Normal file
View File

@ -0,0 +1,78 @@
<?xml version='1.0' encoding='us-ascii'?>
<!DOCTYPE meshers PUBLIC "" "desktop.dtd">
<!-- GUI customization for MESH component -->
<meshers>
<meshers-group name="Standard Meshers"
resources="StdMeshers"
server-lib="libStdMeshersEngine.so"
gui-lib="libStdMeshersGUI.so">
<hypotheses>
<hypothesis type="LocalLength"
label-id="Average length"
icon-id="mesh_hypo_length.png"/>
<hypothesis type="LengthFromEdges"
label-id="Length From Edges (2D Hyp. for Triangulator)"
icon-id="mesh_hypo_length.png"/>
<hypothesis type="NumberOfSegments"
label-id="Nb. Segments"
icon-id="mesh_hypo_segment.png"/>
<hypothesis type="MaxElementArea"
label-id="Max. Triangle Area"
icon-id="mesh_hypo_area.png"/>
<hypothesis type="MaxElementVolume"
label-id="Max. Hexahedron or Tetrahedron Volume"
icon-id="mesh_hypo_volume.png"/>
<hypothesis type="NotConformAllowed"
label-id="Not Conform Mesh Allowed"
icon-id="mesh_hypo_length.png"/>
</hypotheses>
<algorithms>
<algorithm type="Regular_1D"
label-id="Wire discretisation"
icon-id="mesh_algo_regular.png"/>
<algorithm type="MEFISTO_2D"
label-id="Triangle (Mefisto)"
icon-id="mesh_algo_mefisto.png"/>
<algorithm type="Quadrangle_2D"
label-id="Quadrangle (Mapping)"
icon-id="mesh_algo_quad.png"/>
<algorithm type="Hexa_3D"
label-id="Hexahedron (i,j,k)"
icon-id="mesh_algo_hexa.png"/>
</algorithms>
</meshers-group>
<meshers-group name="Your Meshers Group"
resources=""
server-lib=""
gui-lib="">
<hypotheses>
<hypothesis type=""
label-id=""
icon-id=""/>
</hypotheses>
<algorithms>
<algorithm type=""
label-id=""
icon-id=""/>
</algorithms>
</meshers-group>
</meshers>

Binary file not shown.

After

Width:  |  Height:  |  Size: 543 B

BIN
resources/mesh_free_edges.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 489 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 432 B

BIN
resources/mesh_multi_edges.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 480 B

BIN
resources/mesh_points.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 499 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 411 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 912 B

50
src/Controls/Makefile.in Normal file
View File

@ -0,0 +1,50 @@
# SMESH OBJECT : interactive object for SMESH visualization
#
# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
#
# 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.
#
# 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
#
#
#
# File : Makefile.in
# Module : SMESH
top_srcdir=@top_srcdir@
top_builddir=../..
srcdir=@srcdir@
VPATH=.:@srcdir@:@top_srcdir@/idl:$(top_builddir)/idl
@COMMENCE@
EXPORT_HEADERS = SMESH_Controls.hxx
# Libraries targets
LIB = libSMESHControls.la
LIB_SRC = SMESH_Controls.cxx
# Executables targets
BIN = SMESHControls
BIN_SRC =
CPPFLAGS+=$(OCC_INCLUDES) $(BOOST_CPPFLAGS)
LDFLAGS+=$(OCC_KERNEL_LIBS) -L${KERNEL_ROOT_DIR}/lib/salome -lOpUtil -lSMDS
@CONCLUDE@

View File

@ -0,0 +1,42 @@
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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.
//
// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
#include "SMESH_Controls.hxx"
int main(int argc, char** argv)
{
using namespace SMESH::Controls;
new MinimumAngle();
new AspectRatio();
new Warping();
new Taper();
new Skew();
new Area();
new Length();
new MultiConnection();
new FreeBorders();
new LessThan();
new MoreThan();
new EqualTo();
new LogicalNOT();
new LogicalAND();
new LogicalOR();
return 1;
}

View File

@ -0,0 +1,774 @@
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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.
//
// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
#include <set>
#include <gp_Pnt.hxx>
#include <gp_Vec.hxx>
#include <gp_XYZ.hxx>
#include <Precision.hxx>
#include <TColgp_SequenceOfXYZ.hxx>
#include <TColStd_MapOfInteger.hxx>
#include "SMDS_Mesh.hxx"
#include "SMDS_Iterator.hxx"
#include "SMDS_MeshElement.hxx"
#include "SMDS_MeshNode.hxx"
#include "SMESH_Controls.hxx"
/*
AUXILIARY METHODS
*/
static inline double getAngle( const gp_XYZ& P1, const gp_XYZ& P2, const gp_XYZ& P3 )
{
return gp_Vec( P1 - P2 ).Angle( gp_Vec( P3 - P2 ) );
}
static inline double getArea( const gp_XYZ& P1, const gp_XYZ& P2, const gp_XYZ& P3 )
{
gp_Vec aVec1( P2 - P1 );
gp_Vec aVec2( P3 - P1 );
return ( aVec1 ^ aVec2 ).Magnitude() * 0.5;
}
static inline double getArea( const gp_Pnt& P1, const gp_Pnt& P2, const gp_Pnt& P3 )
{
return getArea( P1.XYZ(), P2.XYZ(), P3.XYZ() );
}
static inline double getDistance( const gp_XYZ& P1, const gp_XYZ& P2 )
{
double aDist = gp_Pnt( P1 ).Distance( gp_Pnt( P2 ) );
return aDist;
}
static int getNbMultiConnection( SMDS_Mesh* theMesh, const int theId )
{
if ( theMesh == 0 )
return 0;
const SMDS_MeshElement* anEdge = theMesh->FindElement( theId );
if ( anEdge == 0 || anEdge->GetType() != SMDSAbs_Edge || anEdge->NbNodes() != 2 )
return 0;
TColStd_MapOfInteger aMap;
int aResult = 0;
SMDS_ElemIteratorPtr anIter = anEdge->nodesIterator();
if ( anIter != 0 )
{
while( anIter->more() )
{
const SMDS_MeshNode* aNode = (SMDS_MeshNode*)anIter->next();
if ( aNode == 0 )
return 0;
SMDS_ElemIteratorPtr anElemIter = aNode->GetInverseElementIterator();
while( anElemIter->more() )
{
const SMDS_MeshElement* anElem = anElemIter->next();
if ( anElem != 0 && anElem->GetType() != SMDSAbs_Edge )
{
int anId = anElem->GetID();
if ( anIter->more() ) // i.e. first node
aMap.Add( anId );
else if ( aMap.Contains( anId ) )
aResult++;
}
}
}
}
return aResult;
}
using namespace SMESH::Controls;
/*
FUNCTORS
*/
/*
Class : NumericalFunctor
Description : Base class for numerical functors
*/
NumericalFunctor::NumericalFunctor():
myMesh(NULL)
{}
void NumericalFunctor::SetMesh( SMDS_Mesh* theMesh )
{
myMesh = theMesh;
}
bool NumericalFunctor::getPoints( const int theId,
TColgp_SequenceOfXYZ& theRes ) const
{
theRes.Clear();
if ( myMesh == 0 )
return false;
// Get nodes of the face
const SMDS_MeshElement* anElem = myMesh->FindElement( theId );
if ( anElem == 0 || anElem->GetType() != GetType() )
return false;
int nbNodes = anElem->NbNodes();
SMDS_ElemIteratorPtr anIter = anElem->nodesIterator();
if ( anIter != 0 )
{
while( anIter->more() )
{
const SMDS_MeshNode* aNode = (SMDS_MeshNode*)anIter->next();
if ( aNode != 0 )
theRes.Append( gp_XYZ( aNode->X(), aNode->Y(), aNode->Z() ) );
}
}
return true;
}
/*
Class : MinimumAngle
Description : Functor for calculation of minimum angle
*/
double MinimumAngle::GetValue( long theId )
{
TColgp_SequenceOfXYZ P;
if ( !getPoints( theId, P ) || P.Length() != 3 && P.Length() != 4 )
return 0;
double aMin;
if ( P.Length() == 3 )
{
double A0 = getAngle( P( 3 ), P( 1 ), P( 2 ) );
double A1 = getAngle( P( 1 ), P( 2 ), P( 3 ) );
double A2 = getAngle( P( 2 ), P( 3 ), P( 1 ) );
aMin = Min( A0, Min( A1, A2 ) );
}
else
{
double A0 = getAngle( P( 4 ), P( 1 ), P( 2 ) );
double A1 = getAngle( P( 1 ), P( 2 ), P( 3 ) );
double A2 = getAngle( P( 2 ), P( 3 ), P( 4 ) );
double A3 = getAngle( P( 3 ), P( 4 ), P( 1 ) );
aMin = Min( Min( A0, A1 ), Min( A2, A3 ) );
}
return aMin * 180 / PI;
}
SMDSAbs_ElementType MinimumAngle::GetType() const
{
return SMDSAbs_Face;
}
/*
Class : AspectRatio
Description : Functor for calculating aspect ratio
*/
double AspectRatio::GetValue( long theId )
{
TColgp_SequenceOfXYZ P;
if ( !getPoints( theId, P ) || P.Length() != 3 && P.Length() != 4 )
return 0;
int nbNodes = P.Length();
// Compute lengths of the sides
double aLen[ nbNodes ];
for ( int i = 0; i < nbNodes - 1; i++ )
aLen[ i ] = getDistance( P( i + 1 ), P( i + 2 ) );
aLen[ nbNodes - 1 ] = getDistance( P( 1 ), P( nbNodes ) );
// Compute aspect ratio
if ( nbNodes == 3 )
{
double aMaxLen = Max( aLen[ 0 ], Max( aLen[ 1 ], aLen[ 2 ] ) );
double anArea = getArea( P( 1 ), P( 2 ), P( 3 ) );
static double aCoef = sqrt( 3. ) / 4;
return anArea != 0 ? aCoef * aMaxLen * aMaxLen / anArea : 0;
}
else
{
double aMaxLen = Max( Max( aLen[ 0 ], aLen[ 1 ] ), Max( aLen[ 2 ], aLen[ 3 ] ) );
double aMinLen = Min( Min( aLen[ 0 ], aLen[ 1 ] ), Min( aLen[ 2 ], aLen[ 3 ] ) );
return aMinLen != 0 ? aMaxLen / aMinLen : 0;
}
}
SMDSAbs_ElementType AspectRatio::GetType() const
{
return SMDSAbs_Face;
}
/*
Class : Warping
Description : Functor for calculating warping
*/
double Warping::GetValue( long theId )
{
TColgp_SequenceOfXYZ P;
if ( !getPoints( theId, P ) || P.Length() != 4 )
return 0;
gp_XYZ G = ( P( 1 ) + P( 2 ) + P( 3 ) + P( 4 ) ) / 4;
double A1 = ComputeA( P( 1 ), P( 2 ), P( 3 ), G );
double A2 = ComputeA( P( 2 ), P( 3 ), P( 4 ), G );
double A3 = ComputeA( P( 3 ), P( 4 ), P( 1 ), G );
double A4 = ComputeA( P( 4 ), P( 1 ), P( 2 ), G );
return Max( Max( A1, A2 ), Max( A3, A4 ) );
}
double Warping::ComputeA( const gp_XYZ& thePnt1,
const gp_XYZ& thePnt2,
const gp_XYZ& thePnt3,
const gp_XYZ& theG ) const
{
double aLen1 = gp_Pnt( thePnt1 ).Distance( gp_Pnt( thePnt2 ) );
double aLen2 = gp_Pnt( thePnt2 ).Distance( gp_Pnt( thePnt3 ) );
double L = Min( aLen1, aLen2 ) * 0.5;
gp_XYZ GI = ( thePnt2 - thePnt1 ) / 2. - theG;
gp_XYZ GJ = ( thePnt3 - thePnt2 ) / 2. - theG;
gp_XYZ N = GI.Crossed( GJ );
N.Normalize();
double H = gp_Vec( thePnt2 - theG ).Dot( gp_Vec( N ) );
return asin( fabs( H / L ) ) * 180 / PI;
}
SMDSAbs_ElementType Warping::GetType() const
{
return SMDSAbs_Face;
}
/*
Class : Taper
Description : Functor for calculating taper
*/
double Taper::GetValue( long theId )
{
TColgp_SequenceOfXYZ P;
if ( !getPoints( theId, P ) || P.Length() != 4 )
return 0;
// Compute taper
double J1 = getArea( P( 4 ), P( 1 ), P( 2 ) ) / 2;
double J2 = getArea( P( 3 ), P( 1 ), P( 2 ) ) / 2;
double J3 = getArea( P( 2 ), P( 3 ), P( 4 ) ) / 2;
double J4 = getArea( P( 3 ), P( 4 ), P( 1 ) ) / 2;
double JA = 0.25 * ( J1 + J2 + J3 + J4 );
double T1 = fabs( ( J1 - JA ) / JA );
double T2 = fabs( ( J2 - JA ) / JA );
double T3 = fabs( ( J3 - JA ) / JA );
double T4 = fabs( ( J4 - JA ) / JA );
return Max( Max( T1, T2 ), Max( T3, T4 ) );
}
SMDSAbs_ElementType Taper::GetType() const
{
return SMDSAbs_Face;
}
/*
Class : Skew
Description : Functor for calculating skew in degrees
*/
static inline double skewAngle( const gp_XYZ& p1, const gp_XYZ& p2, const gp_XYZ& p3 )
{
gp_XYZ p12 = ( p2 + p1 ) / 2;
gp_XYZ p23 = ( p3 + p2 ) / 2;
gp_XYZ p31 = ( p3 + p1 ) / 2;
return gp_Vec( p31 - p2 ).Angle( p12 - p23 );
}
double Skew::GetValue( long theId )
{
TColgp_SequenceOfXYZ P;
if ( !getPoints( theId, P ) || P.Length() != 3 && P.Length() != 4 )
return 0;
// Compute skew
static double PI2 = PI / 2;
if ( P.Length() == 3 )
{
double A0 = fabs( PI2 - skewAngle( P( 3 ), P( 1 ), P( 2 ) ) );
double A1 = fabs( PI2 - skewAngle( P( 1 ), P( 2 ), P( 3 ) ) );
double A2 = fabs( PI2 - skewAngle( P( 2 ), P( 3 ), P( 1 ) ) );
return Max( A0, Max( A1, A2 ) ) * 180 / PI;
}
else
{
gp_XYZ p12 = ( P( 1 ) + P( 2 ) ) / 2;
gp_XYZ p23 = ( P( 2 ) + P( 3 ) ) / 2;
gp_XYZ p34 = ( P( 3 ) + P( 4 ) ) / 2;
gp_XYZ p41 = ( P( 4 ) + P( 1 ) ) / 2;
double A = fabs( PI2 - gp_Vec( p34 - p12 ).Angle( p23 - p41 ) );
return A * 180 / PI;
}
}
SMDSAbs_ElementType Skew::GetType() const
{
return SMDSAbs_Face;
}
/*
Class : Area
Description : Functor for calculating area
*/
double Area::GetValue( long theId )
{
TColgp_SequenceOfXYZ P;
if ( !getPoints( theId, P ) || P.Length() != 3 && P.Length() != 4 )
return 0;
if ( P.Length() == 3 )
return getArea( P( 1 ), P( 2 ), P( 3 ) );
else
return getArea( P( 1 ), P( 2 ), P( 3 ) ) + getArea( P( 1 ), P( 3 ), P( 4 ) );
}
SMDSAbs_ElementType Area::GetType() const
{
return SMDSAbs_Face;
}
/*
Class : Length
Description : Functor for calculating length off edge
*/
double Length::GetValue( long theId )
{
TColgp_SequenceOfXYZ P;
return getPoints( theId, P ) && P.Length() == 2 ? getDistance( P( 1 ), P( 2 ) ) : 0;
}
SMDSAbs_ElementType Length::GetType() const
{
return SMDSAbs_Edge;
}
/*
Class : MultiConnection
Description : Functor for calculating number of faces conneted to the edge
*/
double MultiConnection::GetValue( long theId )
{
return getNbMultiConnection( myMesh, theId );
}
SMDSAbs_ElementType MultiConnection::GetType() const
{
return SMDSAbs_Edge;
}
/*
PREDICATES
*/
/*
Class : FreeBorders
Description : Predicate for free borders
*/
FreeBorders::FreeBorders()
{
myMesh = 0;
}
void FreeBorders::SetMesh( SMDS_Mesh* theMesh )
{
myMesh = theMesh;
}
bool FreeBorders::IsSatisfy( long theId )
{
return getNbMultiConnection( myMesh, theId ) == 1;
}
SMDSAbs_ElementType FreeBorders::GetType() const
{
return SMDSAbs_Edge;
}
/*
Class : FreeEdges
Description : Predicate for free Edges
*/
FreeEdges::FreeEdges()
{
myMesh = 0;
}
void FreeEdges::SetMesh( SMDS_Mesh* theMesh )
{
myMesh = theMesh;
}
bool FreeEdges::IsSatisfy( long theId )
{
return getNbMultiConnection( myMesh, theId ) == 1;
}
SMDSAbs_ElementType FreeEdges::GetType() const
{
return SMDSAbs_Face;
}
FreeEdges::Border::Border(long thePntId1, long thePntId2){
PntId[0] = thePntId1; PntId[1] = thePntId2;
if(thePntId1 > thePntId2){
PntId[1] = thePntId1; PntId[0] = thePntId2;
}
}
//bool operator<(const FreeEdges::Border& x, const FreeEdges::Border& y){
// if(x.PntId[0] < y.PntId[0]) return true;
// if(x.PntId[0] == y.PntId[0])
// if(x.PntId[1] < y.PntId[1]) return true;
// return false;
//}
namespace SMESH{
namespace Controls{
struct EdgeBorder: public FreeEdges::Border{
long ElemId;
EdgeBorder(long theElemId, long thePntId1, long thePntId2):
FreeEdges::Border(thePntId1,thePntId2),
ElemId(theElemId)
{}
};
bool operator<(const FreeEdges::Border& x, const FreeEdges::Border& y){
if(x.PntId[0] < y.PntId[0]) return true;
if(x.PntId[0] == y.PntId[0])
if(x.PntId[1] < y.PntId[1]) return true;
return false;
}
typedef std::set<EdgeBorder> EdgeBorderS;
inline void UpdateBorders(const EdgeBorder& theBorder,
EdgeBorderS& theRegistry,
EdgeBorderS& theContainer)
{
if(theRegistry.find(theBorder) == theRegistry.end()){
theRegistry.insert(theBorder);
theContainer.insert(theBorder);
}else{
theContainer.erase(theBorder);
}
}
}
}
void FreeEdges::GetBoreders(Borders& theBorders)
{
EdgeBorderS aRegistry;
EdgeBorderS aContainer;
SMDS_FaceIteratorPtr anIter = myMesh->facesIterator();
for(; anIter->more(); ){
const SMDS_MeshFace* anElem = anIter->next();
long anElemId = anElem->GetID();
SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator();
long aNodeId[2];
const SMDS_MeshElement* aNode;
if(aNodesIter->more()){
aNode = aNodesIter->next();
aNodeId[0] = aNodeId[1] = aNode->GetID();
}
for(; aNodesIter->more(); ){
aNode = aNodesIter->next();
EdgeBorder aBorder(anElemId,aNodeId[1],aNode->GetID());
aNodeId[1] = aNode->GetID();
//std::cout<<aBorder.PntId[0]<<"; "<<aBorder.PntId[1]<<"; "<<aBorder.ElemId<<"\n";
UpdateBorders(aBorder,aRegistry,aContainer);
}
EdgeBorder aBorder(anElemId,aNodeId[0],aNodeId[1]);
UpdateBorders(aBorder,aRegistry,aContainer);
}
//std::cout<<"aContainer.size() = "<<aContainer.size()<<"\n";
if(aContainer.size()){
EdgeBorderS::const_iterator anIter = aContainer.begin();
for(; anIter != aContainer.end(); anIter++){
const EdgeBorder& aBorder = *anIter;
//std::cout<<aBorder.PntId[0]<<"; "<<aBorder.PntId[1]<<"; "<<aBorder.ElemId<<"\n";
theBorders.insert(Borders::value_type(aBorder.ElemId,aBorder));
}
}
}
/*
Class : Comparator
Description : Base class for comparators
*/
Comparator::Comparator():
myMargin(0)
{}
Comparator::~Comparator()
{}
void Comparator::SetMesh( SMDS_Mesh* theMesh )
{
if ( myFunctor )
myFunctor->SetMesh( theMesh );
}
void Comparator::SetMargin( double theValue )
{
myMargin = theValue;
}
void Comparator::SetNumFunctor( NumericalFunctorPtr theFunct )
{
myFunctor = theFunct;
}
SMDSAbs_ElementType Comparator::GetType() const
{
return myFunctor ? myFunctor->GetType() : SMDSAbs_All;
}
/*
Class : LessThan
Description : Comparator "<"
*/
bool LessThan::IsSatisfy( long theId )
{
return myFunctor && myFunctor->GetValue( theId ) < myMargin;
}
/*
Class : MoreThan
Description : Comparator ">"
*/
bool MoreThan::IsSatisfy( long theId )
{
return myFunctor && myFunctor->GetValue( theId ) > myMargin;
}
/*
Class : EqualTo
Description : Comparator "="
*/
EqualTo::EqualTo():
myToler(Precision::Confusion())
{}
bool EqualTo::IsSatisfy( long theId )
{
return myFunctor && fabs( myFunctor->GetValue( theId ) - myMargin ) < myToler;
}
void EqualTo::SetTolerance( double theToler )
{
myToler = theToler;
}
/*
Class : LogicalNOT
Description : Logical NOT predicate
*/
LogicalNOT::LogicalNOT()
{}
LogicalNOT::~LogicalNOT()
{}
bool LogicalNOT::IsSatisfy( long theId )
{
return myPredicate && !myPredicate->IsSatisfy( theId );
}
void LogicalNOT::SetMesh( SMDS_Mesh* theMesh )
{
if ( myPredicate )
myPredicate->SetMesh( theMesh );
}
void LogicalNOT::SetPredicate( PredicatePtr thePred )
{
myPredicate = thePred;
}
SMDSAbs_ElementType LogicalNOT::GetType() const
{
return myPredicate ? myPredicate->GetType() : SMDSAbs_All;
}
/*
Class : LogicalBinary
Description : Base class for binary logical predicate
*/
LogicalBinary::LogicalBinary()
{}
LogicalBinary::~LogicalBinary()
{}
void LogicalBinary::SetMesh( SMDS_Mesh* theMesh )
{
if ( myPredicate1 )
myPredicate1->SetMesh( theMesh );
if ( myPredicate2 )
myPredicate2->SetMesh( theMesh );
}
void LogicalBinary::SetPredicate1( PredicatePtr thePredicate )
{
myPredicate1 = thePredicate;
}
void LogicalBinary::SetPredicate2( PredicatePtr thePredicate )
{
myPredicate2 = thePredicate;
}
SMDSAbs_ElementType LogicalBinary::GetType() const
{
if ( !myPredicate1 || !myPredicate2 )
return SMDSAbs_All;
SMDSAbs_ElementType aType1 = myPredicate1->GetType();
SMDSAbs_ElementType aType2 = myPredicate2->GetType();
return aType1 == aType2 ? aType1 : SMDSAbs_All;
}
/*
Class : LogicalAND
Description : Logical AND
*/
bool LogicalAND::IsSatisfy( long theId )
{
return
myPredicate1 &&
myPredicate2 &&
myPredicate1->IsSatisfy( theId ) &&
myPredicate2->IsSatisfy( theId );
}
/*
Class : LogicalOR
Description : Logical OR
*/
bool LogicalOR::IsSatisfy( long theId )
{
return
myPredicate1 &&
myPredicate2 &&
myPredicate1->IsSatisfy( theId ) ||
myPredicate2->IsSatisfy( theId );
}
/*
FILTER
*/
Filter::Filter()
{}
Filter::~Filter()
{}
void Filter::SetPredicate( PredicatePtr thePredicate )
{
myPredicate = thePredicate;
}
Filter::TIdSequence
Filter::GetElementsId( SMDS_Mesh* theMesh )
{
TIdSequence aSequence;
if ( !theMesh || !myPredicate ) return aSequence;
myPredicate->SetMesh( theMesh );
SMDSAbs_ElementType aType = myPredicate->GetType();
switch(aType){
case SMDSAbs_Edge:{
SMDS_EdgeIteratorPtr anIter = theMesh->edgesIterator();
if ( anIter != 0 ) {
while( anIter->more() ) {
const SMDS_MeshElement* anElem = anIter->next();
long anId = anElem->GetID();
if ( myPredicate->IsSatisfy( anId ) )
aSequence.push_back( anId );
}
}
}
case SMDSAbs_Face:{
SMDS_FaceIteratorPtr anIter = theMesh->facesIterator();
if ( anIter != 0 ) {
while( anIter->more() ) {
const SMDS_MeshElement* anElem = anIter->next();
long anId = anElem->GetID();
if ( myPredicate->IsSatisfy( anId ) )
aSequence.push_back( anId );
}
}
}
}
return aSequence;
}

View File

@ -0,0 +1,340 @@
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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.
//
// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
#ifndef _SMESH_CONTROLS_HXX_
#define _SMESH_CONTROLS_HXX_
#include <map>
#include <vector>
#include <boost/shared_ptr.hpp>
#include "SMDSAbs_ElementType.hxx"
class SMDS_Mesh;
class gp_Pnt;
class gp_XYZ;
class TColgp_SequenceOfXYZ;
namespace SMESH{
namespace Controls{
class Functor{
public:
~Functor(){}
virtual void SetMesh( SMDS_Mesh* theMesh ) = 0;
};
typedef boost::shared_ptr<Functor> FunctorPtr;
class NumericalFunctor: public virtual Functor{
public:
NumericalFunctor();
virtual void SetMesh( SMDS_Mesh* theMesh );
virtual double GetValue( long theElementId ) = 0;
virtual SMDSAbs_ElementType GetType() const = 0;
protected:
bool getPoints( const int theId,
TColgp_SequenceOfXYZ& theRes ) const;
protected:
SMDS_Mesh* myMesh;
};
typedef boost::shared_ptr<NumericalFunctor> NumericalFunctorPtr;
/*
Class : SMESH_MinimumAngle
Description : Functor for calculation of minimum angle
*/
class MinimumAngle: public virtual NumericalFunctor{
public:
virtual double GetValue( long theElementId );
virtual SMDSAbs_ElementType GetType() const;
};
/*
Class : AspectRatio
Description : Functor for calculating aspect ratio
*/
class AspectRatio: public virtual NumericalFunctor{
public:
virtual double GetValue( long theElementId );
virtual SMDSAbs_ElementType GetType() const;
};
/*
Class : Warping
Description : Functor for calculating warping
*/
class Warping: public virtual NumericalFunctor{
public:
virtual double GetValue( long theElementId );
virtual SMDSAbs_ElementType GetType() const;
private:
double ComputeA( const gp_XYZ&, const gp_XYZ&,
const gp_XYZ&, const gp_XYZ& ) const;
};
/*
Class : Taper
Description : Functor for calculating taper
*/
class Taper: public virtual NumericalFunctor{
public:
virtual double GetValue( long theElementId );
virtual SMDSAbs_ElementType GetType() const;
};
/*
Class : Skew
Description : Functor for calculating skew in degrees
*/
class Skew: public virtual NumericalFunctor{
public:
virtual double GetValue( long theElementId );
virtual SMDSAbs_ElementType GetType() const;
};
/*
Class : Area
Description : Functor for calculating area
*/
class Area: public virtual NumericalFunctor{
public:
virtual double GetValue( long theElementId );
virtual SMDSAbs_ElementType GetType() const;
};
/*
Class : Length
Description : Functor for calculating length of edge
*/
class Length: public virtual NumericalFunctor{
public:
virtual double GetValue( long theElementId );
virtual SMDSAbs_ElementType GetType() const;
};
/*
Class : MultiConnection
Description : Functor for calculating number of faces conneted to the edge
*/
class MultiConnection: public virtual NumericalFunctor{
public:
virtual double GetValue( long theElementId );
virtual SMDSAbs_ElementType GetType() const;
};
/*
PREDICATES
*/
/*
Class : Predicate
Description : Base class for all predicates
*/
class Predicate: public virtual Functor{
public:
virtual bool IsSatisfy( long theElementId ) = 0;
virtual SMDSAbs_ElementType GetType() const = 0;
};
typedef boost::shared_ptr<Predicate> PredicatePtr;
/*
Class : FreeBorders
Description : Predicate for free borders
*/
class FreeBorders: public virtual Predicate{
public:
FreeBorders();
virtual void SetMesh( SMDS_Mesh* theMesh );
virtual bool IsSatisfy( long theElementId );
virtual SMDSAbs_ElementType GetType() const;
protected:
SMDS_Mesh* myMesh;
};
/*
Class : FreeEdges
Description : Predicate for free Edges
*/
class FreeEdges: public virtual Predicate{
public:
FreeEdges();
virtual void SetMesh( SMDS_Mesh* theMesh );
virtual bool IsSatisfy( long theElementId );
virtual SMDSAbs_ElementType GetType() const;
struct Border{
long PntId[2];
Border(long thePntId1, long thePntId2);
};
typedef long TElemId;
typedef std::map<TElemId,Border> Borders;
void GetBoreders(Borders& theBorders);
protected:
SMDS_Mesh* myMesh;
};
typedef boost::shared_ptr<FreeEdges> FreeEdgesPtr;
/*
Class : Comparator
Description : Base class for comparators
*/
class Comparator: public virtual Predicate{
public:
Comparator();
virtual ~Comparator();
virtual void SetMesh( SMDS_Mesh* theMesh );
virtual void SetMargin(double theValue);
virtual void SetNumFunctor(NumericalFunctorPtr theFunct);
virtual bool IsSatisfy( long theElementId ) = 0;
virtual SMDSAbs_ElementType GetType() const;
protected:
double myMargin;
NumericalFunctorPtr myFunctor;
};
typedef boost::shared_ptr<Comparator> ComparatorPtr;
/*
Class : LessThan
Description : Comparator "<"
*/
class LessThan: public virtual Comparator{
public:
virtual bool IsSatisfy( long theElementId );
};
/*
Class : MoreThan
Description : Comparator ">"
*/
class MoreThan: public virtual Comparator{
public:
virtual bool IsSatisfy( long theElementId );
};
/*
Class : EqualTo
Description : Comparator "="
*/
class EqualTo: public virtual Comparator{
public:
EqualTo();
virtual bool IsSatisfy( long theElementId );
virtual void SetTolerance( double theTol );
private:
double myToler;
};
typedef boost::shared_ptr<EqualTo> EqualToPtr;
/*
Class : LogicalNOT
Description : Logical NOT predicate
*/
class LogicalNOT: public virtual Predicate{
public:
LogicalNOT();
virtual ~LogicalNOT();
virtual bool IsSatisfy( long theElementId );
virtual void SetMesh( SMDS_Mesh* theMesh );
virtual void SetPredicate(PredicatePtr thePred);
virtual SMDSAbs_ElementType GetType() const;
private:
PredicatePtr myPredicate;
};
typedef boost::shared_ptr<LogicalNOT> LogicalNOTPtr;
/*
Class : LogicalBinary
Description : Base class for binary logical predicate
*/
class LogicalBinary: public virtual Predicate{
public:
LogicalBinary();
virtual ~LogicalBinary();
virtual void SetMesh( SMDS_Mesh* theMesh );
virtual void SetPredicate1(PredicatePtr thePred);
virtual void SetPredicate2(PredicatePtr thePred);
virtual SMDSAbs_ElementType GetType() const;
protected:
PredicatePtr myPredicate1;
PredicatePtr myPredicate2;
};
typedef boost::shared_ptr<LogicalBinary> LogicalBinaryPtr;
/*
Class : LogicalAND
Description : Logical AND
*/
class LogicalAND: public virtual LogicalBinary{
public:
virtual bool IsSatisfy( long theElementId );
};
/*
Class : LogicalOR
Description : Logical OR
*/
class LogicalOR: public virtual LogicalBinary{
public:
virtual bool IsSatisfy( long theElementId );
};
/*
FILTER
*/
class Filter{
public:
Filter();
virtual ~Filter();
virtual void SetPredicate(PredicatePtr thePred);
typedef std::vector<long> TIdSequence;
virtual TIdSequence GetElementsId( SMDS_Mesh* theMesh );
protected:
PredicatePtr myPredicate;
};
};
};
#endif

View File

@ -0,0 +1,36 @@
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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.
//
// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
#include "Driver_Document.h"
Driver_Document::Driver_Document():
myDocument(NULL)
{}
void Driver_Document::SetFile(const std::string& theFileName)
{
myFile = theFileName;
}
void Driver_Document::SetDocument(SMESHDS_Document * theDocument)
{
myDocument = theDocument;
}

View File

@ -0,0 +1,44 @@
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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.
//
// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
#ifndef _INCLUDE_DRIVER_DOCUMENT
#define _INCLUDE_DRIVER_DOCUMENT
#include <string>
class SMESHDS_Document;
class Driver_Document
{
public:
Driver_Document();
virtual ~Driver_Document(){}
virtual void Perform() = 0;
void SetFile(const std::string& theFileName);
void SetDocument(SMESHDS_Document *theDocument);
protected:
SMESHDS_Document * myDocument;
std::string myFile;
};
#endif

View File

@ -0,0 +1,46 @@
// SMESH Driver : implementaion of driver for reading and writing
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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.
//
// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : Mesh_Reader.cxx
// Module : SMESH
#include "Driver_Mesh.h"
using namespace std;
Driver_Mesh::Driver_Mesh():
myFile(""),
myMeshId(-1)
{}
void Driver_Mesh::SetMeshId(int theMeshId)
{
myMeshId = theMeshId;
}
void Driver_Mesh::SetFile(const std::string& theFileName)
{
myFile = theFileName;
}

57
src/Driver/Driver_Mesh.h Normal file
View File

@ -0,0 +1,57 @@
// SMESH Driver : implementaion of driver for reading and writing
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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.
//
// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : Mesh_Reader.h
// Module : SMESH
#ifndef _INCLUDE_DRIVER_MESH
#define _INCLUDE_DRIVER_MESH
#include <string>
class Driver_Mesh
{
public:
Driver_Mesh();
virtual ~Driver_Mesh(){}
enum Status {
DRS_OK,
DRS_EMPTY, // a file contains no mesh with the given name
DRS_WARN_RENUMBER, // a file has overlapped ranges of element numbers,
// so the numbers from the file are ignored
DRS_WARN_SKIP_ELEM, // some elements were skipped due to incorrect file data
DRS_FAIL // general failure (exception etc.)
};
virtual Status Perform() = 0;
void SetMeshId(int theMeshId);
void SetFile(const std::string& theFileName);
protected:
std::string myFile;
int myMeshId;
};
#endif

View File

@ -0,0 +1,31 @@
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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.
//
// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
#include "Driver_SMDS_Mesh.h"
using namespace std;
Driver_SMDS_Mesh::Driver_SMDS_Mesh():
myMesh(NULL)
{}
void Driver_SMDS_Mesh::SetMesh(SMDS_Mesh *theMesh)
{
myMesh = theMesh;
}

View File

@ -0,0 +1,38 @@
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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.
//
// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
#ifndef _INCLUDE_DRIVER_SMDS_MESH
#define _INCLUDE_DRIVER_SMDS_MESH
#include "Driver_Mesh.h"
class SMDS_Mesh;
class Driver_SMDS_Mesh: public Driver_Mesh
{
public:
Driver_SMDS_Mesh();
void SetMesh(SMDS_Mesh *theMesh);
protected:
SMDS_Mesh *myMesh;
};
#endif

View File

@ -0,0 +1,31 @@
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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.
//
// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
#include "Driver_SMESHDS_Mesh.h"
using namespace std;
Driver_SMESHDS_Mesh::Driver_SMESHDS_Mesh():
myMesh(NULL)
{}
void Driver_SMESHDS_Mesh::SetMesh(SMESHDS_Mesh *theMesh)
{
myMesh = theMesh;
}

View File

@ -0,0 +1,38 @@
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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.
//
// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
#ifndef _INCLUDE_DRIVER_SMESHDS_MESH
#define _INCLUDE_DRIVER_SMESHDS_MESH
#include "Driver_Mesh.h"
class SMESHDS_Mesh;
class Driver_SMESHDS_Mesh: public Driver_Mesh
{
public:
Driver_SMESHDS_Mesh();
void SetMesh(SMESHDS_Mesh *theMesh);
protected:
SMESHDS_Mesh *myMesh;
};
#endif

View File

@ -0,0 +1,28 @@
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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.
//
// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
#include "DriverDAT_R_SMDS_Mesh.h"
#include "DriverDAT_W_SMDS_Mesh.h"
int main(int argc, char** argv)
{
DriverDAT_R_SMDS_Mesh aR;
DriverDAT_W_SMDS_Mesh aW;
return 1;
}

View File

@ -0,0 +1,367 @@
// SMESH DriverMED : tool to split groups on families
//
// Copyright (C) 2003 CEA
//
// 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.
//
// 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.org
//
//
//
// File : DriverMED_Family.cxx
// Author : Julia DOROVSKIKH
// Module : SMESH
// $Header$
#include "DriverMED_Family.h"
#include <sstream>
//=============================================================================
/*!
* Split each group from list <aGroups> on some parts (families)
* on the basis of the elements membership in other groups from this list.
* Resulting families have no common elements.
*/
//=============================================================================
list<DriverMED_FamilyPtr> DriverMED_Family::MakeFamilies
(const map <int, SMESHDS_SubMesh*>& theSubMeshes,
const list<SMESHDS_Group*>& theGroups,
const bool doGroupOfNodes,
const bool doGroupOfEdges,
const bool doGroupOfFaces,
const bool doGroupOfVolumes)
{
list<DriverMED_FamilyPtr> aFamilies;
string anAllNodesGroupName = "Group_Of_All_Nodes";
string anAllEdgesGroupName = "Group_Of_All_Edges";
string anAllFacesGroupName = "Group_Of_All_Faces";
string anAllVolumesGroupName = "Group_Of_All_Volumes";
// Reserve four ids for families of free elements
// (1 - nodes, -1 - edges, -2 - faces, -3 - volumes).
// 'Free' means here not belonging to any group.
int aNodeFamId = FIRST_NODE_FAMILY;
int aElemFamId = FIRST_ELEM_FAMILY;
// Process sub-meshes
map<int, SMESHDS_SubMesh*>::const_iterator aSMIter = theSubMeshes.begin();
for (; aSMIter != theSubMeshes.end(); aSMIter++)
{
list<DriverMED_FamilyPtr> aSMFams = SplitByType((*aSMIter).second, (*aSMIter).first);
list<DriverMED_FamilyPtr>::iterator aSMFamsIter = aSMFams.begin();
for (; aSMFamsIter != aSMFams.end(); aSMFamsIter++)
{
DriverMED_FamilyPtr aFam2 = (*aSMFamsIter);
list<DriverMED_FamilyPtr>::iterator aFamsIter = aFamilies.begin();
while (aFamsIter != aFamilies.end())
{
DriverMED_FamilyPtr aFam1 = *aFamsIter;
list<DriverMED_FamilyPtr>::iterator aCurrIter = aFamsIter++;
if (aFam1->myType == aFam2->myType)
{
DriverMED_FamilyPtr aCommon (new DriverMED_Family);
aFam1->Split(aFam2, aCommon);
if (!aCommon->IsEmpty())
{
aFamilies.push_back(aCommon);
}
if (aFam1->IsEmpty())
{
aFamilies.erase(aCurrIter);
}
if (aFam2->IsEmpty()) break;
}
}
// The rest elements of family
if (!aFam2->IsEmpty())
{
aFamilies.push_back(aFam2);
}
}
}
// Process groups
list<SMESHDS_Group*>::const_iterator aGroupsIter = theGroups.begin();
for (; aGroupsIter != theGroups.end(); aGroupsIter++)
{
DriverMED_FamilyPtr aFam2 (new DriverMED_Family);
aFam2->Init(*aGroupsIter);
list<DriverMED_FamilyPtr>::iterator aFamsIter = aFamilies.begin();
while (aFamsIter != aFamilies.end())
{
DriverMED_FamilyPtr aFam1 = *aFamsIter;
list<DriverMED_FamilyPtr>::iterator aCurrIter = aFamsIter++;
if (aFam1->myType == aFam2->myType)
{
DriverMED_FamilyPtr aCommon (new DriverMED_Family);
aFam1->Split(aFam2, aCommon);
if (!aCommon->IsEmpty())
{
aFamilies.push_back(aCommon);
}
if (aFam1->IsEmpty())
{
aFamilies.erase(aCurrIter);
}
if (aFam2->IsEmpty()) break;
}
}
// The rest elements of group
if (!aFam2->IsEmpty())
{
aFamilies.push_back(aFam2);
}
}
list<DriverMED_FamilyPtr>::iterator aFamsIter = aFamilies.begin();
for (; aFamsIter != aFamilies.end(); aFamsIter++)
{
DriverMED_FamilyPtr aFam = *aFamsIter;
if (aFam->myType == SMDSAbs_Node) {
aFam->SetId(aNodeFamId++);
if (doGroupOfNodes) aFam->myGroupNames.insert(anAllNodesGroupName);
}
else {
aFam->SetId(aElemFamId--);
if (aFam->myType == SMDSAbs_Edge) {
if (doGroupOfEdges) aFam->myGroupNames.insert(anAllEdgesGroupName);
}
else if (aFam->myType == SMDSAbs_Face) {
if (doGroupOfFaces) aFam->myGroupNames.insert(anAllFacesGroupName);
}
else if (aFam->myType == SMDSAbs_Volume) {
if (doGroupOfVolumes) aFam->myGroupNames.insert(anAllVolumesGroupName);
}
}
}
// Create families for elements, not belonging to any group
if (doGroupOfNodes)
{
DriverMED_FamilyPtr aFreeNodesFam (new DriverMED_Family);
aFreeNodesFam->SetId(REST_NODES_FAMILY);
aFreeNodesFam->myType = SMDSAbs_Node;
aFreeNodesFam->myGroupNames.insert(anAllNodesGroupName);
aFamilies.push_back(aFreeNodesFam);
}
if (doGroupOfEdges)
{
DriverMED_FamilyPtr aFreeEdgesFam (new DriverMED_Family);
aFreeEdgesFam->SetId(REST_EDGES_FAMILY);
aFreeEdgesFam->myType = SMDSAbs_Edge;
aFreeEdgesFam->myGroupNames.insert(anAllEdgesGroupName);
aFamilies.push_back(aFreeEdgesFam);
}
if (doGroupOfFaces)
{
DriverMED_FamilyPtr aFreeFacesFam (new DriverMED_Family);
aFreeFacesFam->SetId(REST_FACES_FAMILY);
aFreeFacesFam->myType = SMDSAbs_Face;
aFreeFacesFam->myGroupNames.insert(anAllFacesGroupName);
aFamilies.push_back(aFreeFacesFam);
}
if (doGroupOfVolumes)
{
DriverMED_FamilyPtr aFreeVolumesFam (new DriverMED_Family);
aFreeVolumesFam->SetId(REST_VOLUMES_FAMILY);
aFreeVolumesFam->myType = SMDSAbs_Volume;
aFreeVolumesFam->myGroupNames.insert(anAllVolumesGroupName);
aFamilies.push_back(aFreeVolumesFam);
}
DriverMED_FamilyPtr aNullFam (new DriverMED_Family);
aNullFam->SetId(0);
aNullFam->myType = SMDSAbs_All;
aFamilies.push_back(aNullFam);
return aFamilies;
}
//=============================================================================
/*!
* Create TFamilyInfo for this family
*/
//=============================================================================
MEDA::PFamilyInfo DriverMED_Family::GetFamilyInfo
(const MEDA::PMeshInfo& theMeshInfo) const
{
string aValue;
ostringstream aStr;
aStr << myId;
aValue = aStr.str();
MED::TStringVector anAttrDescs (1, ""); // 1 attribute with empty description,
MED::TIntVector anAttrIds (1, myId); // Id=0,
MED::TIntVector anAttrVals (1, myId); // Value=0
MEDA::PFamilyInfo anInfo = MEDA::TWrapper::CrFamilyInfo(theMeshInfo,
aValue,
myId,
myGroupNames,
anAttrDescs,anAttrIds,anAttrVals);
// cout << endl;
// cout << "Groups: ";
// set<string>::iterator aGrIter = myGroupNames.begin();
// for (; aGrIter != myGroupNames.end(); aGrIter++)
// {
// cout << " " << *aGrIter;
// }
// cout << endl;
//
// cout << "Elements: ";
// set<const SMDS_MeshElement *>::iterator anIter = myElements.begin();
// for (; anIter != myElements.end(); anIter++)
// {
// cout << " " << (*anIter)->GetID();
// }
// cout << endl;
return anInfo;
}
//=============================================================================
/*!
* Initialize the tool by SMESHDS_Group
*/
//=============================================================================
void DriverMED_Family::Init (SMESHDS_Group* group)
{
// Elements
myElements.clear();
group->InitIterator();
while (group->More())
{
myElements.insert(group->Next());
}
// Type
myType = group->GetType();
// Groups list
myGroupNames.clear();
myGroupNames.insert(string(group->GetStoreName()));
}
//=============================================================================
/*!
* Split <theSubMesh> on some parts (families)
* on the basis of the elements type.
*/
//=============================================================================
list<DriverMED_FamilyPtr> DriverMED_Family::SplitByType (SMESHDS_SubMesh* theSubMesh,
const int theId)
{
list<DriverMED_FamilyPtr> aFamilies;
DriverMED_FamilyPtr aNodesFamily (new DriverMED_Family);
DriverMED_FamilyPtr anEdgesFamily (new DriverMED_Family);
DriverMED_FamilyPtr aFacesFamily (new DriverMED_Family);
DriverMED_FamilyPtr aVolumesFamily (new DriverMED_Family);
char submeshGrpName[ 30 ];
sprintf( submeshGrpName, "SubMesh %d", theId );
SMDS_NodeIteratorPtr aNodesIter = theSubMesh->GetNodes();
while (aNodesIter->more())
{
const SMDS_MeshNode* aNode = aNodesIter->next();
aNodesFamily->AddElement(aNode);
}
SMDS_ElemIteratorPtr anElemsIter = theSubMesh->GetElements();
while (anElemsIter->more())
{
const SMDS_MeshElement* anElem = anElemsIter->next();
switch (anElem->GetType())
{
case SMDSAbs_Edge:
anEdgesFamily->AddElement(anElem);
break;
case SMDSAbs_Face:
aFacesFamily->AddElement(anElem);
break;
case SMDSAbs_Volume:
aVolumesFamily->AddElement(anElem);
break;
default:
break;
}
}
if (!aNodesFamily->IsEmpty()) {
aNodesFamily->SetType(SMDSAbs_Node);
aNodesFamily->AddGroupName(submeshGrpName);
aFamilies.push_back(aNodesFamily);
}
if (!anEdgesFamily->IsEmpty()) {
anEdgesFamily->SetType(SMDSAbs_Edge);
anEdgesFamily->AddGroupName(submeshGrpName);
aFamilies.push_back(anEdgesFamily);
}
if (!aFacesFamily->IsEmpty()) {
aFacesFamily->SetType(SMDSAbs_Face);
aFacesFamily->AddGroupName(submeshGrpName);
aFamilies.push_back(aFacesFamily);
}
if (!aVolumesFamily->IsEmpty()) {
aVolumesFamily->SetType(SMDSAbs_Volume);
aVolumesFamily->AddGroupName(submeshGrpName);
aFamilies.push_back(aVolumesFamily);
}
return aFamilies;
}
//=============================================================================
/*!
* Remove from <myElements> elements, common with <by>,
* Remove from <by> elements, common with <myElements>,
* Create family <common> from common elements, with combined groups list.
*/
//=============================================================================
void DriverMED_Family::Split (DriverMED_FamilyPtr by,
DriverMED_FamilyPtr common)
{
// Elements
set<const SMDS_MeshElement *>::iterator anIter = by->myElements.begin();
for (; anIter != by->myElements.end(); anIter++)
{
if (myElements.find(*anIter) != myElements.end())
{
common->myElements.insert(*anIter);
myElements.erase(*anIter);
by->myElements.erase(*anIter);
}
}
if (!common->IsEmpty())
{
// Groups list
common->myGroupNames = myGroupNames;
set<string>::iterator aGrNamesIter = by->myGroupNames.begin();
for (; aGrNamesIter != by->myGroupNames.end(); aGrNamesIter++)
{
common->myGroupNames.insert(*aGrNamesIter);
}
// Type
common->myType = myType;
}
}

View File

@ -0,0 +1,121 @@
// SMESH DriverMED : tool to split groups on families
//
// Copyright (C) 2003 CEA
//
// 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.
//
// 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.org
//
//
//
// File : DriverMED_Family.hxx
// Author : Julia DOROVSKIKH
// Module : SMESH
// $Header$
#ifndef _INCLUDE_DRIVERMED_FAMILY
#define _INCLUDE_DRIVERMED_FAMILY
#include "SMDS_Mesh.hxx"
#include "SMESHDS_Group.hxx"
#include "SMESHDS_SubMesh.hxx"
#include "MEDA_Wrapper.hxx"
#include <boost/shared_ptr.hpp>
#include <set>
using namespace std;
#define REST_NODES_FAMILY 1
#define REST_EDGES_FAMILY -1
#define REST_FACES_FAMILY -2
#define REST_VOLUMES_FAMILY -3
#define FIRST_NODE_FAMILY 2
#define FIRST_ELEM_FAMILY -4
class DriverMED_Family;
typedef boost::shared_ptr<DriverMED_Family> DriverMED_FamilyPtr;
class DriverMED_Family
{
public:
// Methods for groups storing to MED
static list<DriverMED_FamilyPtr> MakeFamilies (const map <int, SMESHDS_SubMesh*>& theSubMeshes,
const list<SMESHDS_Group*>& theGroups,
const bool doGroupOfNodes,
const bool doGroupOfEdges,
const bool doGroupOfFaces,
const bool doGroupOfVolumes);
// Split each group from list <theGroups> and each sub-mesh from list <theSubMeshes>
// on some parts (families) on the basis of the elements membership in other groups
// from <theGroups> and other sub-meshes from <theSubMeshes>.
// Resulting families have no common elements.
MEDA::PFamilyInfo GetFamilyInfo (const MEDA::PMeshInfo& theMeshInfo) const;
// Create TFamilyInfo for this family
const set<const SMDS_MeshElement *>& GetElements () const { return myElements; }
// Returns elements of this family
int GetId () const { return myId; }
// Returns a family ID
public:
// Methods for groups reading from MED
void AddElement (const SMDS_MeshElement* theElement) { myElements.insert(theElement); }
void AddGroupName (string theGroupName) { myGroupNames.insert(theGroupName); }
void SetType (const SMDSAbs_ElementType theType) { myType = theType; }
SMDSAbs_ElementType GetType () { return myType; }
bool MemberOf (string theGroupName) const
{ return (myGroupNames.find(theGroupName) != myGroupNames.end()); }
const MED::TStringSet& GetGroupNames () const { return myGroupNames; }
private:
void Init (SMESHDS_Group* group);
// Initialize the tool by SMESHDS_Group
static list<DriverMED_FamilyPtr> SplitByType (SMESHDS_SubMesh* theSubMesh,
const int theId);
// Split <theSubMesh> on some parts (families)
// on the basis of the elements type.
void Split (DriverMED_FamilyPtr by,
DriverMED_FamilyPtr common);
// Remove from <Elements> elements, common with <by>,
// Remove from <by> elements, common with <Elements>,
// Create family <common> from common elements, with combined groups list.
void SetId (const int theId) { myId = theId; }
// Sets a family ID
bool IsEmpty () const { return myElements.empty(); }
// Check, if this family has empty list of elements
private:
int myId;
SMDSAbs_ElementType myType;
set<const SMDS_MeshElement *> myElements;
MED::TStringSet myGroupNames;
};
#endif

View File

@ -0,0 +1,28 @@
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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.
//
// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
#include "DriverMED_R_SMESHDS_Mesh.h"
#include "DriverMED_W_SMESHDS_Mesh.h"
int main(int argc, char** argv)
{
DriverMED_R_SMESHDS_Mesh aR;
DriverMED_W_SMESHDS_Mesh aW;
return 1;
}

View File

@ -0,0 +1,123 @@
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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.
//
// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
#include <fstream>
#include "UNV2411_Structure.hxx"
#include "UNV_Utilities.hxx"
using namespace std;
using namespace UNV;
using namespace UNV2411;
#ifdef _DEBUG_
static int MYDEBUG = 1;
#else
static int MYDEBUG = 0;
#endif
static string _label_dataset = "2411";
UNV2411::TRecord::TRecord():
exp_coord_sys_num(0),
disp_coord_sys_num(0),
color(0)
{}
void UNV2411::Read(std::ifstream& in_stream, TDataSet& theDataSet)
{
if(!in_stream.good())
EXCEPTION(runtime_error,"ERROR: Input file not good.");
/*
* adjust the \p istream to our
* position
*/
if(!beginning_of_dataset(in_stream,_label_dataset))
EXCEPTION(runtime_error,"ERROR: Could not find "<<_label_dataset<<" dataset!");
/**
* always 3 coordinates in the UNV file, no matter
* which dimensionality libMesh is in
*/
TNodeLab aLabel;
std::string num_buf;
for(; !in_stream.eof();){
in_stream >> aLabel ;
if(aLabel == -1){
// end of dataset is reached
break;
}
TRecord aRec;
in_stream>>aRec.exp_coord_sys_num;
in_stream>>aRec.disp_coord_sys_num;
in_stream>>aRec.color;
/*
* take care of the
* floating-point data
*/
for(int d = 0; d < 3; d++){
in_stream>>num_buf;
aRec.coord[d] = D_to_e(num_buf);
}
theDataSet.insert(TDataSet::value_type(aLabel,aRec));
}
}
void UNV2411::Write(std::ofstream& out_stream, const TDataSet& theDataSet)
{
if(!out_stream.good())
EXCEPTION(runtime_error,"ERROR: Output file not good.");
/*
* Write beginning of dataset
*/
out_stream<<" -1\n";
out_stream<<" "<<_label_dataset<<"\n";
TDataSet::const_iterator anIter = theDataSet.begin();
for(; anIter != theDataSet.end(); anIter++){
const TNodeLab& aLabel = anIter->first;
const TRecord& aRec = anIter->second;
char buf[78];
sprintf(buf, "%10d%10d%10d%10d\n",
aLabel,
aRec.exp_coord_sys_num,
aRec.disp_coord_sys_num,
aRec.color);
out_stream<<buf;
// the coordinates
sprintf(buf, "%25.16E%25.16E%25.16E\n",
aRec.coord[0],
aRec.coord[1],
aRec.coord[2]);
out_stream<<buf;
}
/*
* Write end of dataset
*/
out_stream<<" -1\n";
}

View File

@ -0,0 +1,46 @@
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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.
//
// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
#ifndef UNV2411_Structure_HeaderFile
#define UNV2411_Structure_HeaderFile
#include <map>
#include <fstream>
namespace UNV2411{
struct TRecord{
TRecord();
int exp_coord_sys_num; // export coordinate system number
int disp_coord_sys_num; // displacement coordinate system number
int color; // color
double coord[3]; // node coordinates in the part coordinate system
};
typedef int TNodeLab; // type of node label
typedef std::map<TNodeLab,TRecord> TDataSet;
void Read(std::ifstream& in_stream, TDataSet& theDataSet);
void Write(std::ofstream& out_stream, const TDataSet& theDataSet);
};
#endif

View File

@ -0,0 +1,202 @@
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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.
//
// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
#include <fstream>
#include <iomanip>
#include "UNV2412_Structure.hxx"
#include "UNV_Utilities.hxx"
using namespace std;
using namespace UNV;
using namespace UNV2412;
#ifdef _DEBUG_
static int MYDEBUG = 1;
#else
static int MYDEBUG = 0;
#endif
static string _label_dataset = "2412";
UNV2412::TRecord::TRecord():
phys_prop_tab_num(2),
mat_prop_tab_num(1),
color(7),
beam_orientation(0),
beam_fore_end(0),
beam_aft_end(0)
{}
void UNV2412::Read(std::ifstream& in_stream, TDataSet& theDataSet)
{
if(!in_stream.good())
EXCEPTION(runtime_error,"ERROR: Input file not good.");
/*
* adjust the \p istream to our
* position
*/
if(!beginning_of_dataset(in_stream,_label_dataset))
EXCEPTION(runtime_error,"ERROR: Could not find "<<_label_dataset<<" dataset!");
TElementLab aLabel;
for(; !in_stream.eof();){
in_stream >> aLabel ;
if(aLabel == -1){
// end of dataset is reached
break;
}
int n_nodes;
TRecord aRec;
in_stream>>aRec.fe_descriptor_id;
in_stream>>aRec.phys_prop_tab_num;
in_stream>>aRec.mat_prop_tab_num;
in_stream>>aRec.color;
in_stream>>n_nodes;
if(IsBeam(aRec.fe_descriptor_id)){
in_stream>>aRec.beam_orientation;
in_stream>>aRec.beam_fore_end;
in_stream>>aRec.beam_aft_end;
}
aRec.node_labels.resize(n_nodes);
for(int j=0; j < n_nodes; j++){
// read node labels
in_stream>>aRec.node_labels[j];
}
theDataSet.insert(TDataSet::value_type(aLabel,aRec));
}
}
void UNV2412::Write(std::ofstream& out_stream, const TDataSet& theDataSet)
{
if(!out_stream.good())
EXCEPTION(runtime_error,"ERROR: Output file not good.");
/*
* Write beginning of dataset
*/
out_stream<<" -1\n";
out_stream<<" "<<_label_dataset<<"\n";
TDataSet::const_iterator anIter = theDataSet.begin();
for(; anIter != theDataSet.end(); anIter++){
const TElementLab& aLabel = anIter->first;
const TRecord& aRec = anIter->second;
out_stream<<std::setw(10)<<aLabel; /* element ID */
out_stream<<std::setw(10)<<aRec.fe_descriptor_id; /* type of element */
out_stream<<std::setw(10)<<aRec.phys_prop_tab_num;
out_stream<<std::setw(10)<<aRec.mat_prop_tab_num;
out_stream<<std::setw(10)<<aRec.color;
out_stream<<std::setw(10)<<aRec.node_labels.size()<<std::endl; /* No. of nodes per element */
if(IsBeam(aRec.fe_descriptor_id)){
out_stream<<std::setw(10)<<aRec.beam_orientation;
out_stream<<std::setw(10)<<aRec.beam_fore_end;
out_stream<<std::setw(10)<<aRec.beam_aft_end<<std::endl;
}
int n_nodes = aRec.node_labels.size();
int iEnd = (n_nodes-1)/8 + 1;
for(int i = 0, k = 0; i < iEnd; i++){
int jEnd = n_nodes - 8*(i+1);
if(jEnd < 0)
jEnd = 8 + jEnd;
else
jEnd = 8;
for(int j = 0; j < jEnd ; k++, j++){
out_stream<<std::setw(10)<<aRec.node_labels[k];
}
out_stream<<std::endl;
}
}
/*
* Write end of dataset
*/
out_stream<<" -1\n";
}
bool UNV2412::IsBeam(int theFeDescriptorId){
switch (theFeDescriptorId){
case 11:
case 21:
case 22:
case 24:
case 25:
return true;
}
return false;
}
bool UNV2412::IsFace(int theFeDescriptorId){
switch (theFeDescriptorId){
case 71: // TRI3
case 72:
case 74:
case 41: // Plane Stress Linear Triangle - TRI3
case 91: // Thin Shell Linear Triangle - TRI3
case 42: // Plane Stress Quadratic Triangle - TRI6
case 92: // Thin Shell Quadratic Triangle - TRI6
case 43: // Plane Stress Cubic Triangle
case 44: // Plane Stress Linear Quadrilateral - QUAD4
case 94: // Thin Shell Linear Quadrilateral - QUAD4
case 45: // Plane Stress Quadratic Quadrilateral - QUAD8
case 95: // Thin Shell Quadratic Quadrilateral - QUAD8
case 46: // Plane Stress Cubic Quadrilateral
return true;
}
return false;
}
bool UNV2412::IsVolume(int theFeDescriptorId){
//if(!IsBeam(theFeDescriptorId) && !IsFace(theFeDescriptorId))
// return true;
switch (theFeDescriptorId){
case 111: // Solid Linear Tetrahedron - TET4
case 118: // Solid Quadratic Tetrahedron - TET10
case 112: // Solid Linear Prism - PRISM6
case 115: // Solid Linear Brick - HEX8
case 116: // Solid Quadratic Brick - HEX20
case 117: // Solid Cubic Brick
return true;
}
return false;
}

View File

@ -0,0 +1,59 @@
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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.
//
// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
#ifndef UNV2412_Structure_HeaderFile
#define UNV2412_Structure_HeaderFile
#include <map>
#include <vector>
#include <fstream>
namespace UNV2412{
struct TRecord{
TRecord();
int fe_descriptor_id; // FE descriptor id
int phys_prop_tab_num; // physical property table number
int mat_prop_tab_num; // material property table number
int color; // color
std::vector<int> node_labels; // node labels defining element
//FOR BEAM ELEMENTS ONLY
int beam_orientation; // beam orientation node number
int beam_fore_end; // beam fore-end cross section number
int beam_aft_end; // beam aft-end cross section number
};
typedef int TElementLab; // type of element label
typedef std::map<TElementLab,TRecord> TDataSet;
void Read(std::ifstream& in_stream, TDataSet& theDataSet);
void Write(std::ofstream& out_stream, const TDataSet& theDataSet);
bool IsBeam(int theFeDescriptorId);
bool IsFace(int theFeDescriptorId);
bool IsVolume(int theFeDescriptorId);
};
#endif

View File

@ -0,0 +1,69 @@
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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.
//
// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
#include "UNV2411_Structure.hxx"
#include "UNV2412_Structure.hxx"
#include "UNV_Utilities.hxx"
#include "DriverUNV_R_SMDS_Mesh.h"
#include "DriverUNV_W_SMDS_Mesh.h"
using namespace std;
#ifdef DEBUG
static int MYDEBUG = 1;
#else
static int MYDEBUG = 0;
#endif
void ReadMed(const char* theFileName){
std::ifstream in_stream(theFileName);
UNV2411::TDataSet aDataSet2411;
UNV2411::Read(in_stream,aDataSet2411);
in_stream.seekg(0);
UNV2412::TDataSet aDataSet2412;
UNV2412::Read(in_stream,aDataSet2412);
string aFileName(theFileName);
aFileName += "-";
std::ofstream out_stream(aFileName.c_str());
UNV2411::Write(out_stream,aDataSet2411);
UNV2412::Write(out_stream,aDataSet2412);
}
int main(int argc, char** argv){
DriverUNV_R_SMDS_Mesh aR;
DriverUNV_W_SMDS_Mesh aW;
try{
if(argc > 1){
ReadMed(argv[1]);
}
return 0;
}catch(std::exception& exc){
cout<<"Follow exception was accured :\n"<<exc.what()<<endl;
}catch(...){
cout<<"Unknown exception was accured !!!"<<endl;
}
return 1;
}

View File

@ -0,0 +1,37 @@
// Copyright (C) 2003 CEA/DEN, EDF R&D
//
//
//
// File : VISU_DatConvertor.cxx
// Author : Alexey PETROV
// Module : VISU
#include "UNV_Utilities.hxx"
using namespace std;
#ifdef _DEBUG_
static int MYDEBUG = 1;
#else
static int MYDEBUG = 0;
#endif
int UNV::PrefixPrinter::myCounter = 0;
UNV::PrefixPrinter::PrefixPrinter()
{
myCounter++;
}
UNV::PrefixPrinter::~PrefixPrinter()
{
myCounter--;
}
string UNV::PrefixPrinter::GetPrefix()
{
if(myCounter)
return string(myCounter*2,' ');
return "";
}

View File

@ -0,0 +1,104 @@
// Copyright (C) 2003 CEA/DEN, EDF R&D
//
//
//
// File : VISU_DatConvertor.hxx
// Author : Alexey PETROV
// Module : VISU
#ifndef MED_Utilities_HeaderFile
#define MED_Utilities_HeaderFile
#include <iostream>
#include <sstream>
#include <string>
#include <stdexcept>
namespace UNV{
using namespace std;
class PrefixPrinter{
static int myCounter;
public:
PrefixPrinter();
~PrefixPrinter();
static string GetPrefix();
};
/**
* @returns \p false when error occured, \p true otherwise.
* Adjusts the \p in_stream to the beginning of the
* dataset \p ds_name.
*/
inline bool beginning_of_dataset(std::istream& in_file, const std::string& ds_name)
{
assert (in_file.good());
assert (!ds_name.empty());
std::string olds, news;
while(true){
in_file >> olds >> news;
/*
* a "-1" followed by a number means the beginning of a dataset
* stop combing at the end of the file
*/
while( ((olds != "-1") || (news == "-1") ) && !in_file.eof() ){
olds = news;
in_file >> news;
}
if(in_file.eof())
return false;
if (news == ds_name)
return true;
}
// should never end up here
return false;
}
/**
* Method for converting exponential notation
* from "D" to "e", for example
* \p 3.141592654D+00 \p --> \p 3.141592654e+00
* in order to make it readable for C++.
*/
inline double D_to_e(std::string& number)
{
/* find "D" in string, start looking at
* 6th element, to improve speed.
* We dont expect a "D" earlier
*/
const int position = number.find("D",6);
if(position != std::string::npos){
number.replace(position, 1, "e");
}
return atof (number.c_str());
}
};
#ifndef MESSAGE
#define MESSAGE(msg) std::cout<<__FILE__<<"["<<__LINE__<<"]::"<<msg<<endl;
#define BEGMSG(msg) std::cout<<UNV::PrefixPrinter::GetPrefix()<<msg
#define ADDMSG(msg) std::cout<<msg
#endif
#ifndef EXCEPTION
#define EXCEPTION(TYPE, MSG) {\
std::ostringstream aStream;\
aStream<<__FILE__<<"["<<__LINE__<<"]::"<<MSG;\
throw TYPE(aStream.str());\
}
#endif
#endif

View File

@ -0,0 +1,67 @@
# SMESH NETGENPlugin : implementaion of SMESH idl descriptions
#
# Copyright (C) 2004 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
#
# 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.
#
# 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
#
#
#
# File : Makefile.in
# Author : Julia DOROVSKIKH
# Module : SMESH
# $Header$
top_srcdir=@top_srcdir@
top_builddir=../..
srcdir=@srcdir@
VPATH=.:@srcdir@:@top_srcdir@/idl:$(top_builddir)/idl:
@COMMENCE@
EXPORT_PYSCRIPTS =
# .po files to transform in .qm
PO_FILES = NETGENPlugin_icons.po
# Libraries targets
LIB = libNETGENEngine.la
LIB_SRC = \
NETGENPlugin_NETGEN_3D.cxx \
NETGENPlugin_NETGEN_3D_i.cxx \
NETGENPlugin_i.cxx
LIB_SERVER_IDL = SMESH_NetgenAlgorithm.idl
LIB_CLIENT_IDL = SMESH_Gen.idl SMESH_Mesh.idl SMESH_Group.idl
# Executables targets
BIN =
BIN_SRC =
# additionnal information to compil and link file
NETGEN_INCLUDES=@NETGEN_INCLUDES@
CPPFLAGS+= $(OCC_INCLUDES) $(HDF5_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome \
-I${GEOM_ROOT_DIR}/include/salome $(NETGEN_INCLUDES) $(BOOST_CPPFLAGS)
CXXFLAGS+= $(OCC_CXXFLAGS) $(HDF5_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome \
-I${GEOM_ROOT_DIR}/include/salome $(NETGEN_INCLUDES)
LDFLAGS+= $(HDF5_LIBS) -lSMESHimpl -lSMESHEngine -lStdMeshers -lStdMeshersEngine -lNETGEN -L${KERNEL_ROOT_DIR}/lib/salome -L${GEOM_ROOT_DIR}/lib/salome -lSalomeGenericObj
@CONCLUDE@

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,43 @@
//=============================================================================
// File : NETGENPlugin_NETGEN_3D.hxx
// Moved here from SMESH_NETGEN_3D.hxx
// Created : lundi 27 Janvier 2003
// Author : Nadir BOUHAMOU (CEA)
// Project : SALOME
// Copyright : CEA 2003
// $Header$
//=============================================================================
#ifndef _NETGENPlugin_NETGEN_3D_HXX_
#define _NETGENPlugin_NETGEN_3D_HXX_
#include "SMESH_3D_Algo.hxx"
#include "SMESH_Mesh.hxx"
#include "StdMeshers_MaxElementVolume.hxx"
#include "Utils_SALOME_Exception.hxx"
class NETGENPlugin_NETGEN_3D: public SMESH_3D_Algo
{
public:
NETGENPlugin_NETGEN_3D(int hypId, int studyId, SMESH_Gen* gen);
virtual ~NETGENPlugin_NETGEN_3D();
virtual bool CheckHypothesis(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape,
SMESH_Hypothesis::Hypothesis_Status& aStatus);
virtual bool Compute(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape);
ostream & SaveTo(ostream & save);
istream & LoadFrom(istream & load);
friend ostream & operator << (ostream & save, NETGENPlugin_NETGEN_3D & hyp);
friend istream & operator >> (istream & load, NETGENPlugin_NETGEN_3D & hyp);
protected:
double _maxElementVolume;
const StdMeshers_MaxElementVolume* _hypMaxElementVolume;
};
#endif

View File

@ -0,0 +1,85 @@
// SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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.
//
// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : NETGENPlugin_NETGEN_3D_i.cxx
// Moved here from SMESH_NETGEN_3D_i.cxx
// Author : Nadir Bouhamou CEA
// Module : SMESH
// $Header$
using namespace std;
#include "NETGENPlugin_NETGEN_3D_i.hxx"
#include "SMESH_Gen.hxx"
#include "Utils_CorbaException.hxx"
#include "utilities.h"
//=============================================================================
/*!
* NETGENPlugin_NETGEN_3D_i::NETGENPlugin_NETGEN_3D_i
*
* Constructor
*/
//=============================================================================
NETGENPlugin_NETGEN_3D_i::NETGENPlugin_NETGEN_3D_i( PortableServer::POA_ptr thePOA,
int theStudyId,
::SMESH_Gen* theGenImpl )
: SALOME::GenericObj_i( thePOA ),
SMESH_Hypothesis_i( thePOA ),
SMESH_Algo_i( thePOA ),
SMESH_3D_Algo_i( thePOA )
{
MESSAGE( "NETGENPlugin_NETGEN_3D_i::NETGENPlugin_NETGEN_3D_i" );
myBaseImpl = new ::NETGENPlugin_NETGEN_3D( theGenImpl->GetANewId(),
theStudyId,
theGenImpl );
}
//=============================================================================
/*!
* NETGENPlugin_NETGEN_3D_i::~NETGENPlugin_NETGEN_3D_i
*
* Destructor
*/
//=============================================================================
NETGENPlugin_NETGEN_3D_i::~NETGENPlugin_NETGEN_3D_i()
{
MESSAGE( "NETGENPlugin_NETGEN_3D_i::~NETGENPlugin_NETGEN_3D_i" );
}
//=============================================================================
/*!
* NETGENPlugin_NETGEN_3D_i::GetImpl
*
* Get implementation
*/
//=============================================================================
::NETGENPlugin_NETGEN_3D* NETGENPlugin_NETGEN_3D_i::GetImpl()
{
MESSAGE( "NETGENPlugin_NETGEN_3D_i::GetImpl" );
return ( ::NETGENPlugin_NETGEN_3D* )myBaseImpl;
}

View File

@ -0,0 +1,58 @@
// SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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.
//
// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : NETGENPlugin_NETGEN_3D_i.hxx
// Moved here from SMESH_NETGEN_3D_i.hxx
// Author : Nadir Bouhamou CEA
// Module : SMESH
// $Header$
#ifndef _NETGENPlugin_NETGEN_3D_I_HXX_
#define _NETGENPlugin_NETGEN_3D_I_HXX_
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_NetgenAlgorithm)
#include "SMESH_3D_Algo_i.hxx"
#include "NETGENPlugin_NETGEN_3D.hxx"
// ======================================================
// NETGEN 3d algorithm
// ======================================================
class NETGENPlugin_NETGEN_3D_i:
public virtual POA_NETGENPlugin::NETGENPlugin_NETGEN_3D,
public virtual SMESH_3D_Algo_i
{
public:
// Constructor
NETGENPlugin_NETGEN_3D_i( PortableServer::POA_ptr thePOA,
int theStudyId,
::SMESH_Gen* theGenImpl );
// Destructor
virtual ~NETGENPlugin_NETGEN_3D_i();
// Get implementation
::NETGENPlugin_NETGEN_3D* GetImpl();
};
#endif

View File

@ -0,0 +1,60 @@
// SMESH NETGENPlugin : implementaion of SMESH idl descriptions
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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.
//
// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : NETGENPlugin.cxx
// Author : Julia DOROVSKIKH
// Module : SMESH
// $Header$
using namespace std;
#include "SMESH_Hypothesis_i.hxx"
#include "SMESH_Gen_i.hxx"
#include "utilities.h"
#include "NETGENPlugin_NETGEN_3D_i.hxx"
//=============================================================================
/*!
*
*/
//=============================================================================
extern "C"
{
GenericHypothesisCreator_i* GetHypothesisCreator (const char* aHypName)
{
MESSAGE("GetHypothesisCreator " << aHypName);
GenericHypothesisCreator_i* aCreator = 0;
// Hypotheses
// Algorithms
if (strcmp(aHypName, "NETGEN_3D") == 0)
aCreator = new HypothesisCreator_i<NETGENPlugin_NETGEN_3D_i>;
else ;
return aCreator;
}
}

View File

@ -0,0 +1,20 @@
# This is a Qt message file in .po format. Each msgid starts with
# a scope. This scope should *NOT* be translated - eg. "Foo::Bar"
# would be translated to "Pub", not "Foo::Pub".
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"POT-Creation-Date: 2002-05-28 10:57:43 AM CEST\n"
"PO-Revision-Date: YYYY-MM-DD\n"
"Last-Translator: FULLNAME <EMAIL@ADDRESS>\n"
"Content-Type: text/plain; charset=iso-8859-1\n"
#-----------------------------------------------------------
# ObjectBrowser
#-----------------------------------------------------------
#mesh_tree_algo_netgen
msgid "ICON_SMESH_TREE_ALGO_NETGEN_3D"
msgstr "mesh_tree_algo_tetra.png"
#msgstr "mesh_tree_algo_netgen.png"

View File

@ -0,0 +1,357 @@
// SMESH OBJECT : interactive object for SMESH visualization
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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.
//
// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : SMESH_Actor.cxx
// Author : Nicolas REJNERI
// Module : SMESH
// $Header$
#include "SMESH_DeviceActor.h"
#include "SALOME_Transform.h"
#include "SALOME_TransformFilter.h"
#include "SALOME_PassThroughFilter.h"
#include "SALOME_ExtractUnstructuredGrid.h"
#include "utilities.h"
// VTK Includes
#include <vtkObjectFactory.h>
#include <vtkShrinkFilter.h>
#include <vtkShrinkPolyData.h>
#include <vtkProperty.h>
#include <vtkPolyData.h>
#include <vtkMergeFilter.h>
#include <vtkPolyDataMapper.h>
#include <vtkUnstructuredGrid.h>
#ifdef _DEBUG_
static int MYDEBUG = 0;
static int MYDEBUGWITHFILES = 0;
#else
static int MYDEBUG = 0;
static int MYDEBUGWITHFILES = 0;
#endif
using namespace std;
vtkStandardNewMacro(SMESH_DeviceActor);
SMESH_DeviceActor::SMESH_DeviceActor(){
if(MYDEBUG) MESSAGE("SMESH_DeviceActor");
myIsShrunk = false;
myIsShrinkable = false;
myRepresentation = eSurface;
myProperty = vtkProperty::New();
myMapper = vtkPolyDataMapper::New();
vtkMapper::GetResolveCoincidentTopologyPolygonOffsetParameters(myPolygonOffsetFactor,
myPolygonOffsetUnits);
//myMapper->SetResolveCoincidentTopologyToShiftZBuffer();
//myMapper->SetResolveCoincidentTopologyZShift(0.02);
myMapper->UseLookupTableScalarRangeOn();
myMapper->SetColorModeToMapScalars();
myShrinkFilter = vtkShrinkFilter::New();
myExtractUnstructuredGrid = SALOME_ExtractUnstructuredGrid::New();
myExtractUnstructuredGrid->SetStoreMapping(true);
myMergeFilter = vtkMergeFilter::New();
myStoreMapping = false;
myGeomFilter = SALOME_GeometryFilter::New();
myTransformFilter = SALOME_TransformFilter::New();
for(int i = 0; i < 6; i++)
myPassFilter.push_back(SALOME_PassThroughFilter::New());
}
SMESH_DeviceActor::~SMESH_DeviceActor(){
if(MYDEBUG) MESSAGE("~SMESH_DeviceActor");
myProperty->Delete();
myMapper->RemoveAllInputs();
myMapper->Delete();
myShrinkFilter->UnRegisterAllOutputs();
myShrinkFilter->Delete();
myExtractUnstructuredGrid->UnRegisterAllOutputs();
myExtractUnstructuredGrid->Delete();
myMergeFilter->UnRegisterAllOutputs();
myMergeFilter->Delete();
myGeomFilter->UnRegisterAllOutputs();
myGeomFilter->Delete();
myTransformFilter->UnRegisterAllOutputs();
myTransformFilter->Delete();
for(int i = 0, iEnd = myPassFilter.size(); i < iEnd; i++){
myPassFilter[i]->UnRegisterAllOutputs();
myPassFilter[i]->Delete();
}
}
void SMESH_DeviceActor::SetStoreMapping(int theStoreMapping){
myStoreMapping = theStoreMapping;
Modified();
}
void SMESH_DeviceActor::SetUnstructuredGrid(vtkUnstructuredGrid* theGrid){
if(theGrid){
//myIsShrinkable = theGrid->GetNumberOfCells() > 10;
myIsShrinkable = true;
myExtractUnstructuredGrid->SetInput(theGrid);
myMergeFilter->SetGeometry(myExtractUnstructuredGrid->GetOutput());
theGrid = static_cast<vtkUnstructuredGrid*>(myMergeFilter->GetOutput());
int anId = 0;
myPassFilter.at( anId )->SetInput( theGrid );
myPassFilter.at( anId + 1)->SetInput( myPassFilter.at( anId )->GetOutput() );
anId++; // 1
myGeomFilter->SetStoreMapping( myStoreMapping );
myGeomFilter->SetInput( myPassFilter.at( anId )->GetOutput() );
anId++; // 2
myPassFilter.at( anId )->SetInput( myGeomFilter->GetOutput() );
myPassFilter.at( anId + 1 )->SetInput( myPassFilter.at( anId )->GetOutput() );
anId++; // 3
myTransformFilter->SetInput( myPassFilter.at( anId )->GetPolyDataOutput() );
anId++; // 4
myPassFilter.at( anId )->SetInput( myTransformFilter->GetOutput() );
myPassFilter.at( anId + 1 )->SetInput( myPassFilter.at( anId )->GetOutput() );
anId++; // 5
myMapper->SetInput( myPassFilter.at( anId )->GetPolyDataOutput() );
vtkLODActor::SetMapper( myMapper );
Modified();
}
}
SALOME_ExtractUnstructuredGrid* SMESH_DeviceActor::GetExtractUnstructuredGrid(){
return myExtractUnstructuredGrid;
}
vtkUnstructuredGrid* SMESH_DeviceActor::GetUnstructuredGrid(){
myExtractUnstructuredGrid->Update();
return myExtractUnstructuredGrid->GetOutput();
}
vtkMergeFilter* SMESH_DeviceActor::GetMergeFilter(){
return myMergeFilter;
}
vtkPolyData* SMESH_DeviceActor::GetPolyDataInput(){
return myPassFilter.back()->GetPolyDataOutput();
}
unsigned long int SMESH_DeviceActor::GetMTime(){
unsigned long mTime = this->Superclass::GetMTime();
mTime = max(mTime,myExtractUnstructuredGrid->GetMTime());
mTime = max(mTime,myMergeFilter->GetMTime());
mTime = max(mTime,myGeomFilter->GetMTime());
mTime = max(mTime,myTransformFilter->GetMTime());
return mTime;
}
void SMESH_DeviceActor::SetTransform(SALOME_Transform* theTransform){
myTransformFilter->SetTransform(theTransform);
}
void SMESH_DeviceActor::SetShrink()
{
if ( !myIsShrinkable ) return;
if ( vtkDataSet* aDataSet = myPassFilter.at( 0 )->GetOutput() )
{
myShrinkFilter->SetInput( aDataSet );
myPassFilter.at( 1 )->SetInput( myShrinkFilter->GetOutput() );
myIsShrunk = true;
}
}
void SMESH_DeviceActor::UnShrink()
{
if ( !myIsShrunk ) return;
if ( vtkDataSet* aDataSet = myPassFilter.at( 0 )->GetOutput() )
{
myPassFilter.at( 1 )->SetInput( aDataSet );
myPassFilter.at( 1 )->Modified();
myIsShrunk = false;
Modified();
}
}
void SMESH_DeviceActor::SetRepresentation(EReperesent theMode){
switch(theMode){
case ePoint:
myGeomFilter->SetInside(true);
GetProperty()->SetRepresentation(0);
break;
case eInsideframe:
myGeomFilter->SetInside(true);
GetProperty()->SetRepresentation(1);
break;
default :
GetProperty()->SetRepresentation(theMode);
myGeomFilter->SetInside(false);
}
myRepresentation = theMode;
myMapper->Modified();
Modified();
}
void SMESH_DeviceActor::SetVisibility(int theMode){
if(!myExtractUnstructuredGrid->GetInput() || GetUnstructuredGrid()->GetNumberOfCells()){
vtkLODActor::SetVisibility(theMode);
}else{
vtkLODActor::SetVisibility(false);
}
}
int SMESH_DeviceActor::GetVisibility(){
if(!GetUnstructuredGrid()->GetNumberOfCells()){
vtkLODActor::SetVisibility(false);
}
return vtkLODActor::GetVisibility();
}
int SMESH_DeviceActor::GetObjId(int theVtkID){
if (GetRepresentation() == ePoint){
return GetNodeObjId(theVtkID);
}else{
return GetElemObjId(theVtkID);
}
}
SMESH_DeviceActor::TVectorId SMESH_DeviceActor::GetVtkId(int theObjID){
if (GetRepresentation() == ePoint){
return GetNodeVtkId(theObjID);
}else{
return GetElemVtkId(theObjID);
}
}
int SMESH_DeviceActor::GetNodeObjId(int theVtkID){
vtkIdType aRetID = myVisualObj->GetNodeObjId(theVtkID);
if(MYDEBUG) MESSAGE("GetNodeObjId - theVtkID = "<<theVtkID<<"; aRetID = "<<aRetID);
return aRetID;
}
SMESH_DeviceActor::TVectorId SMESH_DeviceActor::GetNodeVtkId(int theObjID){
SMESH_DeviceActor::TVectorId aVecId;
vtkIdType anID = myVisualObj->GetNodeVTKId(theObjID);
if(anID < 0)
return aVecId;
aVecId.push_back(anID);
return aVecId;
}
int SMESH_DeviceActor::GetElemObjId(int theVtkID){
vtkIdType aGridID = myGeomFilter->GetObjId(theVtkID);
if(aGridID < 0)
return -1;
vtkIdType anExtractID = myExtractUnstructuredGrid->GetOutId(aGridID);
if(anExtractID < 0)
return -1;
vtkIdType aRetID = myVisualObj->GetElemObjId(anExtractID);
if(MYDEBUG)
MESSAGE("GetElemObjId - theVtkID = "<<theVtkID<<"; anExtractID = "<<anExtractID<<"; aGridID = "<<aGridID<<"; aRetID = "<<aRetID);
return aRetID;
}
SMESH_DeviceActor::TVectorId SMESH_DeviceActor::GetElemVtkId(int theObjID){
TVectorId aVecId;
vtkIdType aGridID = myVisualObj->GetElemVTKId(theObjID);
if(aGridID < 0)
return aVecId;
aVecId = myGeomFilter->GetVtkId(aGridID);
if(MYDEBUG)
MESSAGE("GetElemVtkId - theObjID = "<<theObjID<<"; aGridID = "<<aGridID<<"; aGridID = "<<aGridID<<"; aVecId[0] = "<<aVecId[0]);
return aVecId;
}
float SMESH_DeviceActor::GetShrinkFactor(){
return myShrinkFilter->GetShrinkFactor();
}
void SMESH_DeviceActor::SetShrinkFactor(float theValue){
theValue = theValue > 0.1? theValue: 0.8;
myShrinkFilter->SetShrinkFactor(theValue);
Modified();
}
void SMESH_DeviceActor::Render(vtkRenderer *ren, vtkMapper* m){
int aResolveCoincidentTopology = vtkMapper::GetResolveCoincidentTopology();
float aFactor, aUnit;
vtkMapper::GetResolveCoincidentTopologyPolygonOffsetParameters(aFactor,aUnit);
vtkMapper::SetResolveCoincidentTopologyToPolygonOffset();
vtkMapper::SetResolveCoincidentTopologyPolygonOffsetParameters(myPolygonOffsetFactor,
myPolygonOffsetUnits);
vtkLODActor::Render(ren,m);
vtkMapper::SetResolveCoincidentTopologyPolygonOffsetParameters(aFactor,aUnit);
vtkMapper::SetResolveCoincidentTopology(aResolveCoincidentTopology);
}
void SMESH_DeviceActor::SetPolygonOffsetParameters(float factor, float units){
myPolygonOffsetFactor = factor;
myPolygonOffsetUnits = units;
}

View File

@ -0,0 +1,133 @@
// SMESH OBJECT : interactive object for SMESH visualization
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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.
//
// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : SMESH_Actor.h
// Author : Nicolas REJNERI
// Module : SMESH
// $Header$
#ifndef SMESH_DEVICE_ACTOR_H
#define SMESH_DEVICE_ACTOR_H
#include "SALOME_GeometryFilter.h"
#include "SMESH_Object.h"
#include <vtkLODActor.h>
class vtkProperty;
class vtkMergeFilter;
class vtkShrinkFilter;
class vtkPolyDataMapper;
class vtkUnstructuredGrid;
class SALOME_Transform;
class SALOME_TransformFilter;
class SALOME_PassThroughFilter;
class SALOME_ExtractUnstructuredGrid;
class SMESH_DeviceActor: public vtkLODActor{
friend class SMESH_Actor;
public:
vtkTypeMacro(SMESH_DeviceActor,vtkLODActor);
static SMESH_DeviceActor* New();
void SetStoreMapping(int theStoreMapping);
int GetStoreMapping(){ return myStoreMapping;}
typedef SALOME_GeometryFilter::TVectorId TVectorId;
int GetObjId(int theVtkID);
TVectorId GetVtkId(int theObjID);
int GetNodeObjId(int theVtkID);
TVectorId GetNodeVtkId(int theObjID);
int GetElemObjId(int theVtkID);
TVectorId GetElemVtkId(int theObjID);
vtkPolyData* GetPolyDataInput();
virtual void SetTransform(SALOME_Transform* theTransform);
virtual unsigned long int GetMTime();
float GetShrinkFactor();
void SetShrinkFactor(float value);
bool IsShrunkable() { return myIsShrinkable;}
bool IsShrunk() { return myIsShrunk;}
void SetShrink();
void UnShrink();
enum EReperesent { ePoint, eWireframe, eSurface, eInsideframe};
EReperesent GetRepresentation(){ return myRepresentation;}
void SetRepresentation(EReperesent theMode);
virtual void SetVisibility(int theMode);
virtual int GetVisibility();
SALOME_ExtractUnstructuredGrid* GetExtractUnstructuredGrid();
vtkUnstructuredGrid* GetUnstructuredGrid();
vtkMergeFilter* GetMergeFilter();
virtual void Render(vtkRenderer *, vtkMapper *);
protected:
void SetUnstructuredGrid(vtkUnstructuredGrid* theGrid);
vtkPolyDataMapper *myMapper;
TVisualObjPtr myVisualObj;
vtkProperty *myProperty;
EReperesent myRepresentation;
vtkMergeFilter* myMergeFilter;
SALOME_ExtractUnstructuredGrid* myExtractUnstructuredGrid;
bool myStoreMapping;
SALOME_GeometryFilter *myGeomFilter;
SALOME_TransformFilter *myTransformFilter;
std::vector<SALOME_PassThroughFilter*> myPassFilter;
vtkShrinkFilter* myShrinkFilter;
bool myIsShrinkable;
bool myIsShrunk;
float myPolygonOffsetFactor;
float myPolygonOffsetUnits;
void SetPolygonOffsetParameters(float factor, float units);
void GetPolygonOffsetParameters(float& factor, float& units){
factor = myPolygonOffsetFactor;
units = myPolygonOffsetUnits;
}
SMESH_DeviceActor();
~SMESH_DeviceActor();
SMESH_DeviceActor(const SMESH_DeviceActor&) {};
void operator=(const SMESH_DeviceActor&) {};
};
#endif //SMESH_ACTOR_H

1037
src/OBJECT/SMESH_Object.cxx Normal file

File diff suppressed because it is too large Load Diff

207
src/OBJECT/SMESH_Object.h Normal file
View File

@ -0,0 +1,207 @@
// SMESH OBJECT : interactive object for SMESH visualization
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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.
//
// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : SMESH_Object.h
// Author : Nicolas REJNERI
// Module : SMESH
// $Header$
#ifndef SMESH_OBJECT_H
#define SMESH_OBJECT_H
// IDL Headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_Mesh)
#include CORBA_SERVER_HEADER(SMESH_Group)
#include CORBA_SERVER_HEADER(SMESH_Filter)
#include <map>
#include <list>
#include <boost/shared_ptr.hpp>
#include <vtkSystemIncludes.h>
class vtkUnstructuredGrid;
class vtkPoints;
class SALOME_ExtractUnstructuredGrid;
class SMESH_Actor;
class SMDS_Mesh;
class SMDS_MeshNode;
class SMDS_MeshElement;
class SMESH_VisualObj;
typedef boost::shared_ptr<SMESH_VisualObj> TVisualObjPtr;
/*
Class : SMESH_VisualObj
Description : Base class for all mesh objects to be visuilised
*/
class SMESH_VisualObj
{
protected:
typedef std::list<const SMDS_MeshElement*> TEntityList;
typedef std::map<vtkIdType,vtkIdType> TMapOfIds;
public:
SMESH_VisualObj();
virtual ~SMESH_VisualObj();
virtual void Update( int theIsClear = true ) = 0;
virtual void UpdateFunctor( SMESH::Functor_ptr theFunctor ) = 0;
virtual int GetElemDimension( const int theObjId ) = 0;
virtual int GetNbEntities( const SMESH::ElementType) const = 0;
virtual int GetEntities( const SMESH::ElementType, TEntityList& ) const = 0;
virtual bool IsNodePrs() const = 0;
vtkUnstructuredGrid* GetUnstructuredGrid() { return myGrid; }
vtkIdType GetNodeObjId( int theVTKID );
vtkIdType GetNodeVTKId( int theObjID );
vtkIdType GetElemObjId( int theVTKID );
vtkIdType GetElemVTKId( int theObjID );
protected:
void createPoints( vtkPoints* );
void buildPrs();
void buildNodePrs();
void buildElemPrs();
private:
TMapOfIds mySMDS2VTKNodes;
TMapOfIds myVTK2SMDSNodes;
TMapOfIds mySMDS2VTKElems;
TMapOfIds myVTK2SMDSElems;
vtkUnstructuredGrid* myGrid;
};
/*
Class : SMESH_MeshObj
Description : Class for visualisation of mesh
*/
class SMESH_MeshObj: public SMESH_VisualObj
{
public:
SMESH_MeshObj( SMESH::SMESH_Mesh_ptr );
virtual ~SMESH_MeshObj();
virtual void Update( int theIsClear = true );
virtual int GetNbEntities( const SMESH::ElementType) const;
virtual int GetEntities( const SMESH::ElementType, TEntityList& ) const;
virtual bool IsNodePrs() const;
virtual int GetElemDimension( const int theObjId );
virtual void UpdateFunctor( SMESH::Functor_ptr f );
SMESH::SMESH_Mesh_ptr GetMeshServer() { return myMeshServer.in(); }
SMDS_Mesh* GetMesh() { return myMesh; }
protected:
SMESH::SMESH_Mesh_var myMeshServer;
SMDS_Mesh* myMesh;
};
/*
Class : SMESH_SubMeshObj
Description : Base class for visualisation of submeshes and groups
*/
class SMESH_SubMeshObj: public SMESH_VisualObj
{
public:
SMESH_SubMeshObj(SMESH_MeshObj* theMeshObj);
virtual ~SMESH_SubMeshObj();
virtual void Update( int theIsClear = true );
virtual void UpdateFunctor( SMESH::Functor_ptr );
virtual int GetElemDimension( const int theObjId );
protected:
SMESH_MeshObj* myMeshObj;
};
/*
Class : SMESH_GroupObj
Description : Class for visualisation of groups
*/
class SMESH_GroupObj: public SMESH_SubMeshObj
{
public:
SMESH_GroupObj( SMESH::SMESH_Group_ptr, SMESH_MeshObj* );
virtual ~SMESH_GroupObj();
virtual int GetNbEntities( const SMESH::ElementType) const;
virtual int GetEntities( const SMESH::ElementType, TEntityList& ) const;
virtual bool IsNodePrs() const;
private:
SMESH::SMESH_Group_var myGroupServer;
};
/*
Class : SMESH_subMeshObj
Description : Class for visualisation of submeshes
*/
class SMESH_subMeshObj : public SMESH_SubMeshObj
{
public:
SMESH_subMeshObj( SMESH::SMESH_subMesh_ptr,
SMESH_MeshObj* );
virtual ~SMESH_subMeshObj();
virtual int GetNbEntities( const SMESH::ElementType) const;
virtual int GetEntities( const SMESH::ElementType, TEntityList& ) const;
virtual bool IsNodePrs() const;
protected:
SMESH::SMESH_subMesh_var mySubMeshServer;
};
extern void WriteUnstructuredGrid(vtkUnstructuredGrid* theGrid, const char* theFileName);
#endif

55
src/SMESH/SMESH_Group.cxx Normal file
View File

@ -0,0 +1,55 @@
// SMESH SMESH : implementaion of SMESH idl descriptions
//
// Copyright (C) 2004 CEA
//
// 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.
//
// 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.org
//
//
//
// File : SMESH_Group.cxx
// Author : Michael Sazonov (OCC)
// Module : SMESH
// $Header$
#include <SMESH_Group.hxx>
#include <SMESH_Mesh.hxx>
#include <SMESHDS_Group.hxx>
//=============================================================================
/*!
*
*/
//=============================================================================
SMESH_Group::SMESH_Group (const SMESH_Mesh* theMesh,
const SMDSAbs_ElementType theType,
const char* theName)
: myName(theName)
{
myGroupDS = new SMESHDS_Group (const_cast<SMESH_Mesh*>(theMesh)->GetMeshDS(), theType);
}
//=============================================================================
/*!
*
*/
//=============================================================================
SMESH_Group::~SMESH_Group ()
{
delete myGroupDS;
}

64
src/SMESH/SMESH_Group.hxx Normal file
View File

@ -0,0 +1,64 @@
// SMESH SMESH : implementaion of SMESH idl descriptions
//
// Copyright (C) 2004 CEA
//
// 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.
//
// 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.org
//
//
//
// File : SMESH_Group.hxx
// Author : Michael Sazonov (OCC)
// Module : SMESH
// $Header$
#ifndef _SMESH_Group_HeaderFile
#define _SMESH_Group_HeaderFile
#include <SMDSAbs_ElementType.hxx>
#include <string>
using namespace std;
class SMESHDS_Group;
class SMESH_Mesh;
class SMESH_Group
{
public:
SMESH_Group (const SMESH_Mesh* theMesh,
const SMDSAbs_ElementType theType,
const char* theName);
~SMESH_Group ();
void SetName (const char* theName) { myName = theName; }
const char* GetName () const { return myName.c_str(); }
SMESHDS_Group * GetGroupDS () { return myGroupDS; }
private:
SMESH_Group (const SMESH_Group& theOther);
// prohibited copy constructor
SMESH_Group& operator = (const SMESH_Group& theOther);
// prohibited assign operator
SMESHDS_Group * myGroupDS;
string myName;
};
#endif

View File

@ -0,0 +1,129 @@
// SMESH SMESHDS : idl implementation based on 'SMESH' unit's classes
//
// Copyright (C) 2004 CEA
//
// 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.
//
// 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.org
//
//
//
// File : SMESHDS_Group.cxx
// Author : Michael Sazonov, OCC
// Module : SMESH
// $Header$
#include <SMESHDS_Group.hxx>
#include <SMESHDS_Mesh.hxx>
//=============================================================================
/*!
*
*/
//=============================================================================
SMESHDS_Group::SMESHDS_Group (const SMESHDS_Mesh* theMesh,
const SMDSAbs_ElementType theType)
: SMDS_MeshGroup(theMesh,theType), myStoreName(""),
myCurIndex(0), myCurID(0)
{
}
//=============================================================================
/*!
*
*/
//=============================================================================
bool SMESHDS_Group::Contains (const int theID) const
{
const SMDS_MeshElement* aElem = findInMesh (theID);
if (aElem)
return SMDS_MeshGroup::Contains(aElem);
return false;
}
//=============================================================================
/*!
*
*/
//=============================================================================
bool SMESHDS_Group::Add (const int theID)
{
const SMDS_MeshElement* aElem = findInMesh (theID);
if (!aElem || SMDS_MeshGroup::Contains(aElem))
return false;
SMDS_MeshGroup::Add (aElem);
return true;
}
//=============================================================================
/*!
*
*/
//=============================================================================
bool SMESHDS_Group::Remove (const int theID)
{
const SMDS_MeshElement* aElem = findInMesh (theID);
if (!aElem || !SMDS_MeshGroup::Contains(aElem))
return false;
SMDS_MeshGroup::Remove (aElem);
return true;
}
//=============================================================================
/*!
*
*/
//=============================================================================
int SMESHDS_Group::GetID (const int theIndex)
{
if (theIndex < 1 || theIndex > Extent())
return -1;
if (myCurIndex < 1 || myCurIndex > theIndex) {
InitIterator();
myCurIndex = 0;
myCurID = -1;
}
while (myCurIndex < theIndex && More()) {
myCurIndex++;
myCurID = Next()->GetID();
}
return myCurID;
}
//=============================================================================
/*!
*
*/
//=============================================================================
const SMDS_MeshElement* SMESHDS_Group::findInMesh (const int theID) const
{
SMDSAbs_ElementType aType = GetType();
const SMDS_MeshElement* aElem = NULL;
if (aType == SMDSAbs_Node) {
aElem = GetMesh()->FindNode(theID);
}
else if (aType != SMDSAbs_All) {
aElem = GetMesh()->FindElement(theID);
if (aElem && aType != aElem->GetType())
aElem = NULL;
}
return aElem;
}

View File

@ -0,0 +1,72 @@
// SMESH SMESHDS : management of mesh data and SMESH document
//
// Copyright (C) 2004 CEA
//
// 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.
//
// 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.org
//
//
//
// File : SMESHDS_Group.hxx
// Author : Michael Sazonov (OCC)
// Module : SMESH
// $Header$
#ifndef _SMESHDS_Group_HeaderFile
#define _SMESHDS_Group_HeaderFile
#include <SMDS_MeshGroup.hxx>
#include <string>
class SMESHDS_Mesh;
class SMESHDS_Group : public SMDS_MeshGroup
{
public:
SMESHDS_Group (const SMESHDS_Mesh* theMesh,
const SMDSAbs_ElementType theType);
void SetStoreName (const char* theName)
{ myStoreName = theName; }
const char* GetStoreName () const
{ return myStoreName.c_str(); }
bool Contains (const int theID) const;
bool Add (const int theID);
bool Remove (const int theID);
int GetID (const int theIndex);
// use it for iterations 1..Extent() as alternative to parent's
// InitIterator(), More(), Next()
private:
SMESHDS_Group (const SMESHDS_Group& theOther);
// prohibited copy constructor
SMESHDS_Group& operator = (const SMESHDS_Group& theOther);
// prohibited assign operator
const SMDS_MeshElement* findInMesh (const int theID) const;
string myStoreName;
int myCurIndex;
int myCurID;
};
#endif

View File

@ -0,0 +1,4 @@
int main(int argc, char** argv){
return 0;
}

View File

@ -0,0 +1,290 @@
// SMESH SMESHGUI : GUI for SMESH component
//
// Copyright (C) 2003 CEA
//
// 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.
//
// 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.org
//
//
//
// File : SMESHGUI_CreateHypothesesDlg.cxx
// Author : Julia DOROVSKIKH
// Module : SMESH
// $Header$
using namespace std;
#include "SMESHGUI_CreateHypothesesDlg.h"
#include "SMESHGUI.h"
#include "SALOME_ListIteratorOfListIO.hxx"
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "utilities.h"
// QT Includes
#include <qbuttongroup.h>
#include <qgroupbox.h>
#include <qpushbutton.h>
#include <qlayout.h>
#include <qlistview.h>
#include <qheader.h>
//=================================================================================
// class : SMESHGUI_CreateHypothesesDlg()
// purpose : Constructs a SMESHGUI_CreateHypothesesDlg which is a child of 'parent', with the
// name 'name' and widget flags set to 'f'.
// The dialog will by default be modeless, unless you set 'modal' to
// TRUE to construct a modal dialog.
//=================================================================================
SMESHGUI_CreateHypothesesDlg::SMESHGUI_CreateHypothesesDlg (QWidget* parent,
const char* name,
bool modal,
bool isAlgo)
: QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose ),
myIsAlgo( isAlgo )
{
MESSAGE("SMESHGUI_CreateHypothesesDlg");
if ( !name )
setName( "SMESHGUI_CreateHypothesesDlg" );
setCaption( isAlgo ? tr( "SMESH_CREATE_ALGORITHMS" ) : tr( "SMESH_CREATE_HYPOTHESES" ) );
setSizeGripEnabled( TRUE );
QGridLayout* SMESHGUI_CreateHypothesesDlgLayout = new QGridLayout( this );
SMESHGUI_CreateHypothesesDlgLayout->setSpacing( 6 );
SMESHGUI_CreateHypothesesDlgLayout->setMargin( 11 );
/***************************************************************/
GroupAlgorithms = new QGroupBox( this, "GroupAlgorithms" );
GroupAlgorithms->setTitle( isAlgo ? tr("SMESH_AVAILABLE_ALGORITHMS") : tr("SMESH_AVAILABLE_HYPOTHESES") );
GroupAlgorithms->setColumnLayout(0, Qt::Vertical );
GroupAlgorithms->layout()->setSpacing( 0 );
GroupAlgorithms->layout()->setMargin( 0 );
QGridLayout* hypLayout = new QGridLayout( GroupAlgorithms->layout() );
hypLayout->setGeometry( QRect( 12, 18, 139, 250 ) );
hypLayout->setAlignment( Qt::AlignTop );
hypLayout->setSpacing( 6 );
hypLayout->setMargin( 11 );
ListAlgoDefinition = new QListView( GroupAlgorithms, "ListAlgoDefinition" );
ListAlgoDefinition->setMinimumSize( 400, 200 );
ListAlgoDefinition->addColumn("");
ListAlgoDefinition->header()->hide();
ListAlgoDefinition->setSelectionMode(QListView::Single);
ListAlgoDefinition->setResizeMode(QListView::AllColumns);
ListAlgoDefinition->setRootIsDecorated( true );
hypLayout->addWidget( ListAlgoDefinition, 0, 0 );
SMESHGUI_CreateHypothesesDlgLayout->addWidget( GroupAlgorithms, 0, 0 );
/***************************************************************/
GroupButtons = new QGroupBox( this, "GroupButtons" );
GroupButtons->setColumnLayout( 0, Qt::Vertical );
GroupButtons->layout()->setSpacing( 0 );
GroupButtons->layout()->setMargin( 0 );
QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
GroupButtonsLayout->setAlignment( Qt::AlignTop );
GroupButtonsLayout->setSpacing( 6 );
GroupButtonsLayout->setMargin( 11 );
buttonApply = new QPushButton( GroupButtons, "buttonApply" );
buttonApply->setText( tr( "SMESH_BUT_CREATE" ) );
buttonApply->setAutoDefault( TRUE );
buttonApply->setDefault( FALSE );
buttonApply->setEnabled( FALSE ) ;
GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupButtonsLayout->addItem( spacer_9, 0, 2 );
buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) );
buttonCancel->setAutoDefault( TRUE );
buttonCancel->setDefault( TRUE );
buttonCancel->setEnabled( TRUE ) ;
GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
SMESHGUI_CreateHypothesesDlgLayout->addWidget( GroupButtons, 1, 0 );
/***************************************************************/
Init();
}
//=================================================================================
// function : ~SMESHGUI_CreateHypothesesDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
SMESHGUI_CreateHypothesesDlg::~SMESHGUI_CreateHypothesesDlg()
{
// no need to delete child widgets, Qt does it all for us
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void SMESHGUI_CreateHypothesesDlg::Init()
{
mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
InitAlgoDefinition();
/* signals and slots connections */
connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
connect( buttonApply , SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) ) ;
// connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
connect( ListAlgoDefinition, SIGNAL( selectionChanged() ), this, SLOT( onSelectionChanged() ) );
connect( ListAlgoDefinition, SIGNAL( doubleClicked(QListViewItem*) ), this, SLOT( onDoubleClicked(QListViewItem*) ) );
int x, y ;
mySMESHGUI->DefineDlgPosition( this, x, y ) ;
this->move( x, y ) ;
this->show() ;
}
//=================================================================================
// function : ClickOnCancel()
// purpose :
//=================================================================================
void SMESHGUI_CreateHypothesesDlg::ClickOnCancel()
{
close() ;
}
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
void SMESHGUI_CreateHypothesesDlg::ClickOnApply()
{
QListViewItem* item = ListAlgoDefinition->selectedItem();
if ( !item )
return;
QString aHypType = item->text( 1 );
MESSAGE("Apply " << aHypType);
char* sHypType = (char*)aHypType.latin1();
HypothesisData* aHypData = mySMESHGUI->GetHypothesisData(sHypType);
if ( !aHypData )
return;
QString aClientLibName = aHypData->ClientLibName;
MESSAGE("Client lib name = " << aClientLibName);
if (aClientLibName == "")
{
// Call hypothesis creation server method (without GUI)
QString aHypName = aHypData->Label;
mySMESHGUI->CreateHypothesis(sHypType, aHypName, myIsAlgo);
}
else
{
// Get hypotheses creator client (GUI)
SMESHGUI_GenericHypothesisCreator* aCreator =
mySMESHGUI->GetHypothesisCreator(sHypType);
// Create hypothesis/algorithm
aCreator->CreateHypothesis(myIsAlgo, this);
}
// buttonApply->setEnabled(FALSE);
return;
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void SMESHGUI_CreateHypothesesDlg::ActivateThisDialog()
{
mySMESHGUI->EmitSignalDeactivateDialog() ;
GroupButtons->setEnabled(true) ;
return ;
}
//=================================================================================
// function : enterEvent()
// purpose :
//=================================================================================
void SMESHGUI_CreateHypothesesDlg::enterEvent(QEvent* e)
{
ActivateThisDialog() ;
return ;
}
//=================================================================================
// function : closeEvent()
// purpose :
//=================================================================================
void SMESHGUI_CreateHypothesesDlg::closeEvent( QCloseEvent* e )
{
mySMESHGUI->ResetState();
QDialog::closeEvent( e );
}
//=================================================================================
// function : onSelectionChanged()
// purpose :
//=================================================================================
void SMESHGUI_CreateHypothesesDlg::onSelectionChanged()
{
QListViewItem* item = ListAlgoDefinition->selectedItem();
buttonApply->setEnabled( item && item->depth() > 0 ) ;
}
//=================================================================================
// function : onDoubleClicked()
// purpose :
//=================================================================================
void SMESHGUI_CreateHypothesesDlg::onDoubleClicked(QListViewItem* i)
{
if ( i && i->depth() > 0 )
this->ClickOnApply();
}
//=================================================================================
// function : InitAlgoDefinition()
// purpose :
//=================================================================================
void SMESHGUI_CreateHypothesesDlg::InitAlgoDefinition()
{
ListAlgoDefinition->clear();
QStringList HypList = mySMESHGUI->GetAvailableHypotheses(myIsAlgo);
for ( int i = 0; i < HypList.count(); ++i ) {
HypothesisData* aHypData = mySMESHGUI->GetHypothesisData( HypList[i] );
QListViewItem* parentItem = 0;
QListViewItem* childItem = ListAlgoDefinition->firstChild();
while ( childItem ) {
if ( childItem->text(0) == aHypData->PluginName ) {
parentItem = childItem;
break;
}
childItem = childItem->nextSibling();
}
if ( !parentItem )
parentItem = new QListViewItem( ListAlgoDefinition, aHypData->PluginName );
parentItem->setOpen( true );
QListViewItem* aItem = new QListViewItem( parentItem, aHypData->Label, HypList[i] );
QPixmap aPixMap (QAD_Desktop::getResourceManager()->loadPixmap
("SMESH", tr(aHypData->IconId)));
if ( !aPixMap.isNull() )
aItem->setPixmap( 0, aPixMap );
}
}

View File

@ -0,0 +1,97 @@
// SMESH SMESHGUI : GUI for SMESH component
//
// Copyright (C) 2003 CEA
//
// 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.
//
// 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.org
//
//
//
// File : SMESHGUI_CreateHypothesesDlg.h
// Author : Julia DOROVSKIKH
// Module : SMESH
// $Header$
#ifndef DIALOGBOX_CREATE_HYPOTHESES_H
#define DIALOGBOX_CREATE_HYPOTHESES_H
// QT Includes
#include <qvariant.h>
#include <qdialog.h>
#include <qstringlist.h>
// IDL Headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(GEOM_Gen)
#include CORBA_SERVER_HEADER(GEOM_Shape)
#include CORBA_SERVER_HEADER(SMESH_Mesh)
#include <map>
#include <string>
using namespace std;
class QButtonGroup;
class QGroupBox;
class QPushButton;
class QListView;
class QListViewItem;
class SMESHGUI;
//=================================================================================
// class : SMESHGUI_CreateHypothesesDlg
// purpose :
//=================================================================================
class SMESHGUI_CreateHypothesesDlg : public QDialog
{
Q_OBJECT
public:
SMESHGUI_CreateHypothesesDlg (QWidget* parent = 0,
const char* name = 0,
bool modal = FALSE,
bool isAlgo = FALSE);
~SMESHGUI_CreateHypothesesDlg ();
private:
void Init() ;
void closeEvent( QCloseEvent* e ) ;
void enterEvent ( QEvent * ) ;
void InitAlgoDefinition();
SMESHGUI* mySMESHGUI;
bool myIsAlgo;
QGroupBox* GroupButtons;
QPushButton* buttonCancel;
QPushButton* buttonApply;
QGroupBox* GroupAlgorithms;
QListView* ListAlgoDefinition;
private slots:
void ClickOnCancel();
void ClickOnApply();
void ActivateThisDialog() ;
void onSelectionChanged();
void onDoubleClicked(QListViewItem*);
};
#endif // DIALOGBOX_CREATE_HYPOTHESES_H

114
src/SMESHGUI/SMESHGUI_Filter.cxx Executable file
View File

@ -0,0 +1,114 @@
// SMESHGUI_Filter : Filters for VTK viewer
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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.
//
// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : SMESHGUI_Filter.cxx
// Author : Sergey LITONIN
// Module : SMESH
#include "SMESHGUI_Filter.h"
#include <vtkCell.h>
#include <gp_Vec.hxx>
#include <Precision.hxx>
#include "SMESH_Actor.h"
#include "SMESHGUI.h"
IMPLEMENT_STANDARD_HANDLE(SMESHGUI_Filter, VTKViewer_Filter)
IMPLEMENT_STANDARD_RTTIEXT(SMESHGUI_Filter, VTKViewer_Filter)
/*
Class : SMESHGUI_Filter
Description : Selection filter for VTK viewer. This class aggregate object
of SMESH_Filter class and uses it for verification of criterion
*/
//=======================================================================
// name : SMESHGUI_Filter::SMESHGUI_Filter
// Purpose : Constructor
//=======================================================================
SMESHGUI_Filter::SMESHGUI_Filter()
{
myActor = 0;
}
SMESHGUI_Filter::~SMESHGUI_Filter()
{
}
//=======================================================================
// name : SMESHGUI_Filter::IsValid
// Purpose : Verify whether entry id satisfies to criterion of the filter
//=======================================================================
bool SMESHGUI_Filter::IsValid( const int theCellId ) const
{
if ( myActor == 0 || myPred->_is_nil() )
return false;
SMESH_Actor* anActor = ( SMESH_Actor* )myActor;
int aMeshId = anActor->GetElemObjId( theCellId );
return myPred->IsSatisfy( aMeshId );
}
//=======================================================================
// name : SMESHGUI_Filter::SetPredicate
// Purpose : Set new pridicate to the filter
//=======================================================================
void SMESHGUI_Filter::SetPredicate( SMESH::Predicate_ptr thePred )
{
myPred = thePred;
}
//=======================================================================
// name : SMESHGUI_Filter::GetActor
// Purpose : Get actor of the filter
//=======================================================================
SALOME_Actor* SMESHGUI_Filter::GetActor() const
{
return myActor;
}
//=======================================================================
// name : SMESHGUI_Filter::SetActor
// Purpose : Set new actor
//=======================================================================
void SMESHGUI_Filter::SetActor( SALOME_Actor* theActor )
{
if ( myActor == theActor )
return;
VTKViewer_Filter::SetActor( theActor );
if ( myActor != 0 && !myPred->_is_nil() )
{
Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
if ( !anIO.IsNull() )
{
Standard_Boolean aRes = false;
SMESH::SMESH_Mesh_ptr aMeshPtr = SMESHGUI::GetSMESHGUI()->ConvertIOinMesh( anIO, aRes );
if ( aRes )
myPred->SetMesh( aMeshPtr );
}
}
}

68
src/SMESHGUI/SMESHGUI_Filter.h Executable file
View File

@ -0,0 +1,68 @@
// SMESHGUI_Filter : Filters for VTK viewer
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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.
//
// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : SMESHGUI_Filter.h
// Author : Sergey LITONIN
// Module : SMESH
#ifndef SMESHGUI_Filter_HeaderFile
#define SMESHGUI_Filter_HeaderFile
#include "VTKViewer_Filter.h"
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_Filter)
class SALOME_Actor;
DEFINE_STANDARD_HANDLE(SMESHGUI_Filter, VTKViewer_Filter)
/*
Class : SMESHGUI_Filter
Description : Selection filter for VTK viewer
*/
class SMESHGUI_Filter : public VTKViewer_Filter
{
public:
SMESHGUI_Filter();
virtual ~SMESHGUI_Filter();
virtual bool IsValid( const int theCellId ) const;
virtual void SetActor( SALOME_Actor* );
SALOME_Actor* GetActor() const;
void SetPredicate( SMESH::Predicate_ptr );
private:
SMESH::Predicate_var myPred;
public:
DEFINE_STANDARD_RTTI(SMESHGUI_Filter)
};
#endif

File diff suppressed because it is too large Load Diff

195
src/SMESHGUI/SMESHGUI_FilterDlg.h Executable file
View File

@ -0,0 +1,195 @@
// SMESH SMESHGUI : GUI for SMESH component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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.
//
// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : SMESHGUI_FilterDlg.h
// Author : Sergey LITONIN
// Module : SMESH
#ifndef SMESHGUI_FilterDlg_H
#define SMESHGUI_FilterDlg_H
#include <qdialog.h>
#include <qmap.h>
#include <qvaluelist.h>
#include <SALOME_Selection.h>
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_Filter)
#include CORBA_SERVER_HEADER(SMESH_Mesh)
class QCloseEvent;
class QWidgetStack;
class QStringList;
class QTableItem;
class QFrame;
class QEvent;
class QPushButton;
class QTable;
class SALOME_Selection;
class SMESHGUI;
class QComboBox;
class QButtonGroup;
class QCheckBox;
class QGroupBox;
/*
Class : SMESHGUI_FilterDlg
Description : Dialog to specify filters for VTK viewer
*/
class SMESHGUI_FilterDlg : public QDialog
{
Q_OBJECT
class Table;
// Edge criteria
enum { FreeBorders = 0, MultiBorders, Length };
// Face criteria
enum { AspectRatio = 0, Warping, MinimumAngle, Taper, Skew, Area };
// Comparision
enum { LessThan = 0, MoreThan, EqualTo };
// Logical operations
enum { LO_And = 0, LO_Or, LO_Undefined };
// Source elements to be selected
enum { Mesh, Selection, Dialog, None };
typedef QMap<int, Table*> TableMap;
public:
SMESHGUI_FilterDlg( QWidget* parent,
const int type,
const bool theModal = true,
const char* name = 0 );
virtual ~SMESHGUI_FilterDlg();
void Init( const int type );
void SetSelection( SALOME_Selection* );
void SetMesh( SMESH::SMESH_Mesh_ptr );
void SetSourceWg( QWidget* );
private slots:
void onAddBtn();
void onRemoveBtn();
void onClearBtn();
void onCriterionChanged( int, int );
void onOk();
bool onApply();
void onClose();
void onDeactivate();
private:
void closeEvent( QCloseEvent* e );
void enterEvent ( QEvent * );
void updateBtnState();
// dialog creation
QFrame* createButtonFrame( QWidget*, const bool );
QFrame* createMainFrame( QWidget* );
Table* createTable( QWidget*, const int );
QButtonGroup* createSourceGroup( QWidget* );
void addRow( Table*, const int );
QTableItem* getCriterionItem( QTable*, const int );
QTableItem* getCompareItem( QTable* );
QTableItem* getNotItem( QTable* );
QTableItem* getLogOpItem( QTable* );
const QStringList& getCriteria( const int theType ) const;
const QStringList& getCompare () const;
// query
int getCurrType() const;
int getCriterion( const int theType, const int theRow ) const;
// execution
bool isValid() const;
SMESH::Predicate_ptr createPredicate( const int theType );
void insertFilterInViewer( SMESH::Predicate_ptr thePred );
void selectInViewer( const int theType,
const QValueList<int>& theIds );
void filterSource( const int theType,
SMESH::Predicate_ptr thePred,
QValueList<int>& theResIds );
void filterSelectionSource( const int theType,
SMESH::Predicate_ptr thePred,
QValueList<int>& theResIds );
void getIdsFromWg( const QWidget*, QValueList<int>& ) const;
void setIdsToWg( QWidget*, const QValueList<int>& );
Selection_Mode getSelMode( const int ) const;
private:
// widgets
QFrame* myMainFrame;
QGroupBox* myTableGrp;
TableMap myTables;
QPushButton* myAddBtn;
QPushButton* myRemoveBtn;
QPushButton* myClearBtn;
QButtonGroup* mySourceGrp;
QCheckBox* mySetInViewer;
QPushButton* myOkBtn;
QPushButton* myApplyBtn;
QPushButton* myCloseBtn;
// initial fields
int myType;
SMESHGUI* mySMESHGUI;
SALOME_Selection* mySelection;
SMESH::SMESH_Mesh_ptr myMesh;
QWidget* mySourceWg;
};
#endif

View File

@ -0,0 +1,977 @@
// SMESH SMESHGUI : GUI for SMESH component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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.
//
// 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.org
//
//
//
// File : SMESHGUI_GroupDlg.cxx
// Author : Natalia KOPNOVA
// Module : SMESH
// $Header$
using namespace std;
#include "SMESHGUI_GroupDlg.h"
#include "SMESHGUI_FilterDlg.h"
#include "SMESHGUI.h"
#include "SALOMEGUI_QtCatchCorbaException.hxx"
#include "SALOME_ListIteratorOfListIO.hxx"
#include "VTKViewer_InteractorStyleSALOME.h"
#include "VTKViewer_ViewFrame.h"
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "QAD_MessageBox.h"
#include "QAD_RightFrame.h"
#include "utilities.h"
#include "SMESH_Actor.h"
// QT Includes
#include <qbuttongroup.h>
#include <qgroupbox.h>
#include <qhbox.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qradiobutton.h>
#include <qcheckbox.h>
#include <qlayout.h>
#include <qlistbox.h>
#include <qimage.h>
#include <qpixmap.h>
#include <qmemarray.h>
// STL includes
#include <vector>
#include <algorithm>
//=================================================================================
// class : SMESHGUI_GroupDlg()
// purpose :
//=================================================================================
SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( QWidget* parent, const char* name, SALOME_Selection* theSel,
SMESH::SMESH_Mesh_ptr theMesh, bool modal, WFlags fl )
: QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose )
{
if ( !name ) setName( "SMESHGUI_GroupDlg" );
initDialog(theSel, true);
init(theMesh);
/* Move widget on the botton right corner of main widget */
int x, y ;
mySMESHGUI->DefineDlgPosition(this, x, y);
this->move(x, y);
}
SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( QWidget* parent, const char* name, SALOME_Selection* theSel,
SMESH::SMESH_Group_ptr theGroup, bool modal, WFlags fl )
: QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose )
{
if ( !name ) setName( "SMESHGUI_GroupDlg" );
initDialog(theSel, false);
init(theGroup);
/* Move widget on the botton right corner of main widget */
int x, y ;
mySMESHGUI->DefineDlgPosition(this, x, y);
this->move(x, y);
}
void SMESHGUI_GroupDlg::initDialog(SALOME_Selection* theSel, bool create)
{
myFilterDlg = 0;
QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT")));
if (create)
setCaption( tr( "SMESH_CREATE_GROUP_TITLE" ) );
else
setCaption( tr( "SMESH_EDIT_GROUP_TITLE" ) );
setSizeGripEnabled( TRUE );
QVBoxLayout* aMainLayout = new QVBoxLayout(this, 11, 6);
/***************************************************************/
myTypeGroup = new QButtonGroup(1, Qt::Vertical, this, "Group types");
myTypeGroup->setTitle(tr("SMESH_ELEMENTS_TYPE"));
myTypeGroup->setExclusive(true);
QStringList types;
types.append(tr("MESH_NODE"));
types.append(tr("SMESH_EDGE"));
types.append(tr("SMESH_FACE"));
types.append(tr("SMESH_VOLUME"));
QRadioButton* rb;
for (int i = 0; i < types.count(); i++) {
rb = new QRadioButton(types[i], myTypeGroup);
}
myTypeGroup->setEnabled(create);
myTypeId = -1;
/***************************************************************/
QHBox* aNameBox = new QHBox(this, "name box");
QLabel* aName = new QLabel(aNameBox, "name label");
aName->setText(tr("SMESH_NAME"));
aName->setMinimumSize(50,0);
myName = new QLineEdit(aNameBox, "name");
/***************************************************************/
QGroupBox* aContentBox = new QGroupBox(1, Qt::Horizontal, this, "content box");
aContentBox->setTitle(tr("SMESH_CONTENT"));
QFrame* aContent = new QFrame(aContentBox, "content");
QGridLayout* aLayout = new QGridLayout(aContent, 7, 4);
aLayout->setSpacing(6);
aLayout->setAutoAdd(false);
QLabel* aLabel = new QLabel(aContent, "elements label");
aLabel->setText(tr("SMESH_ID_ELEMENTS"));
myElements = new QListBox(aContent, "elements list");
myElements->setSelectionMode(QListBox::Extended);
// myElements->setMinimumHeight(150);
myFilter = new QPushButton(aContent, "filter");
myFilter->setText(tr("SMESH_BUT_FILTER"));
QPushButton* aAddBtn = new QPushButton(aContent, "add");
aAddBtn->setText(tr("SMESH_BUT_ADD"));
QPushButton* aRemoveBtn = new QPushButton(aContent, "remove");
aRemoveBtn->setText(tr("SMESH_BUT_REMOVE"));
QPushButton* aSortBtn = new QPushButton(aContent, "sort");
aSortBtn->setText(tr("SMESH_BUT_SORT"));
aLayout->addWidget(aLabel, 0, 0);
aLayout->addMultiCellWidget(myElements, 1, 6, 0, 0);
aLayout->addWidget(myFilter, 1, 2);
aLayout->addWidget(aAddBtn, 3, 2);
aLayout->addWidget(aRemoveBtn, 4, 2);
aLayout->addWidget(aSortBtn, 6, 2);
aLayout->setColStretch(0, 1);
aLayout->addColSpacing(1, 20);
aLayout->addColSpacing(3, 20);
aLayout->setRowStretch(2, 1);
aLayout->setRowStretch(5, 1);
aContentBox->setMinimumHeight(aContent->sizeHint().height() +
aContentBox->sizeHint().height());
/***************************************************************/
QGroupBox* aSelectBox = new QGroupBox(3, Qt::Horizontal, this, "select box");
aSelectBox->setTitle(tr("SMESH_SELECT_FROM"));
mySelectSubMesh = new QCheckBox(aSelectBox, "submesh checkbox");
mySelectSubMesh->setText(tr("SMESH_SUBMESH"));
mySelectSubMesh->setMinimumSize(50, 0);
mySubMeshBtn = new QPushButton(aSelectBox, "submesh button");
mySubMeshBtn->setText("");
mySubMeshBtn->setPixmap(image0);
mySubMeshLine = new QLineEdit(aSelectBox, "submesh line");
mySubMeshLine->setReadOnly(true);
onSelectSubMesh(false);
mySelectGroup = new QCheckBox(aSelectBox, "group checkbox");
mySelectGroup->setText(tr("SMESH_GROUP"));
mySelectGroup->setMinimumSize(50, 0);
myGroupBtn = new QPushButton(aSelectBox, "group button");
myGroupBtn->setText("");
myGroupBtn->setPixmap(image0);
myGroupLine = new QLineEdit(aSelectBox, "group line");
myGroupLine->setReadOnly(true);
onSelectGroup(false);
aSelectBox->setMinimumHeight(mySubMeshBtn->sizeHint().height() +
myGroupBtn->sizeHint().height() +
aSelectBox->sizeHint().height());
/***************************************************************/
QFrame* aButtons = new QFrame(this, "button box");
aButtons->setFrameStyle(QFrame::Box | QFrame::Sunken);
QHBoxLayout* aBtnLayout = new QHBoxLayout(aButtons, 11, 6);
aBtnLayout->setAutoAdd(false);
QPushButton* aOKBtn = new QPushButton(aButtons, "ok");
aOKBtn->setText(tr("SMESH_BUT_OK"));
aOKBtn->setAutoDefault(true);
aOKBtn->setDefault(true);
QPushButton* aApplyBtn = new QPushButton(aButtons, "apply");
aApplyBtn->setText(tr("SMESH_BUT_APPLY"));
aApplyBtn->setAutoDefault(true);
QPushButton* aCloseBtn = new QPushButton(aButtons, "close");
aCloseBtn->setText(tr("SMESH_BUT_CLOSE"));
aCloseBtn->setAutoDefault(true);
aBtnLayout->addWidget(aOKBtn);
aBtnLayout->addWidget(aApplyBtn);
aBtnLayout->addStretch();
aBtnLayout->addWidget(aCloseBtn);
/***************************************************************/
aMainLayout->addWidget(myTypeGroup);
aMainLayout->addWidget(aNameBox);
aMainLayout->addWidget(aContentBox);
aMainLayout->addWidget(aSelectBox);
aMainLayout->addWidget(aButtons);
/* signals and slots connections */
connect(myTypeGroup, SIGNAL(clicked(int)), this, SLOT(onTypeChanged(int)));
connect(myName, SIGNAL(textChanged(const QString&)), this, SLOT(onNameChanged(const QString&)));
connect(myElements, SIGNAL(selectionChanged()), this, SLOT(onListSelectionChanged()));
connect(myFilter, SIGNAL(clicked()), this, SLOT(setFilters()));
connect(aAddBtn, SIGNAL(clicked()), this, SLOT(onAdd()));
connect(aRemoveBtn, SIGNAL(clicked()), this, SLOT(onRemove()));
connect(aSortBtn, SIGNAL(clicked()), this, SLOT(onSort()));
connect(mySelectSubMesh, SIGNAL(toggled(bool)), this, SLOT(onSelectSubMesh(bool)));
connect(mySelectGroup, SIGNAL(toggled(bool)), this, SLOT(onSelectGroup(bool)));
connect(mySubMeshBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection()));
connect(myGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection()));
connect(aOKBtn, SIGNAL(clicked()), this, SLOT(onOK()));
connect(aApplyBtn, SIGNAL(clicked()), this, SLOT(onApply()));
connect(aCloseBtn, SIGNAL(clicked()), this, SLOT(onClose()));
/* Init selection */
mySelection = theSel;
mySMESHGUI = SMESHGUI::GetSMESHGUI();
mySMESHGUI->SetActiveDialogBox(this);
mySMESHGUI->SetState(800);
mySelectionMode = -1;
mySubMeshFilter = new SMESH_TypeFilter(SUBMESH);
myGroupFilter = new SMESH_TypeFilter(GROUP);
connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(onClose()));
connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(onClose()));
connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(onObjectSelectionChanged()));
updateButtons();
}
//=================================================================================
// function : ~SMESHGUI_GroupDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
SMESHGUI_GroupDlg::~SMESHGUI_GroupDlg()
{
// no need to delete child widgets, Qt does it all for us
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void SMESHGUI_GroupDlg::init(SMESH::SMESH_Mesh_ptr theMesh)
{
/* init data from current selection */
myMesh = SMESH::SMESH_Mesh::_duplicate(theMesh);
myGroup = SMESH::SMESH_Group::_nil();
Standard_Boolean aResult;
myActor = mySMESHGUI->FindActor(myMesh, aResult, true);
mySMESHGUI->SetPickable(myActor);
myTypeGroup->setButton(0);
onTypeChanged(0);
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void SMESHGUI_GroupDlg::init(SMESH::SMESH_Group_ptr theGroup)
{
myMesh = theGroup->GetMesh();
myGroup = SMESH::SMESH_Group::_duplicate(theGroup);
Standard_Boolean aResult;
myActor = mySMESHGUI->FindActor(myMesh, aResult, true);
if ( !myActor )
myActor = mySMESHGUI->FindActor(myGroup, aResult, true);
mySMESHGUI->SetPickable(myActor);
int aType = 0;
switch(theGroup->GetType()) {
case SMESH::NODE: aType= 0; break;
case SMESH::EDGE: aType = 1; break;
case SMESH::FACE: aType = 2; break;
case SMESH::VOLUME: aType = 3; break;
}
myTypeGroup->setButton(aType);
onTypeChanged(aType);
myName->setText(myGroup->GetName());
myName->home(false);
if (!theGroup->IsEmpty()) {
SMESH::long_array_var anElements = myGroup->GetListOfID();
int k = anElements->length();
for (int i = 0; i < k; i++) {
myIdList.append(anElements[i]);
myElements->insertItem(QString::number(anElements[i]));
}
myElements->selectAll(true);
}
}
//=================================================================================
// function : updateButtons()
// purpose :
//=================================================================================
void SMESHGUI_GroupDlg::updateButtons()
{
bool enable = !myName->text().stripWhiteSpace().isEmpty() && myElements->count() > 0;
QPushButton* aBtn;
aBtn = (QPushButton*) child("ok", "QPushButton");
if (aBtn) aBtn->setEnabled(enable);
aBtn = (QPushButton*) child("apply", "QPushButton");
if (aBtn) aBtn->setEnabled(enable);
}
//=================================================================================
// function : onNameChanged()
// purpose :
//=================================================================================
void SMESHGUI_GroupDlg::onNameChanged(const QString& text)
{
updateButtons();
}
//=================================================================================
// function : onTypeChanged()
// purpose : Radio button management
//=================================================================================
void SMESHGUI_GroupDlg::onTypeChanged(int id)
{
if (myTypeId != id) {
myElements->clear();
if (myCurrentLineEdit == 0)
setSelectionMode(id);
myFilter->setEnabled(id == 1 || id == 2);
}
myTypeId = id;
}
//=================================================================================
// function : setSelectionMode()
// purpose : Radio button management
//=================================================================================
void SMESHGUI_GroupDlg::setSelectionMode(int theMode)
{
if (mySelectionMode != theMode) {
mySelection->ClearIObjects();
mySelection->ClearFilters();
if (mySelectionMode == 0)
mySMESHGUI->EraseSimulationActors();
if (theMode < 4) {
if (theMode == 0) {
mySMESHGUI->ViewNodes();
QAD_Application::getDesktop()->SetSelectionMode(NodeSelection, true);
}
else if (theMode == 1) {
QAD_Application::getDesktop()->SetSelectionMode(EdgeSelection, true);
}
else if (theMode == 2) {
QAD_Application::getDesktop()->SetSelectionMode(FaceSelection, true);
}
else {
QAD_Application::getDesktop()->SetSelectionMode(VolumeSelection, true);
}
}
else {
QAD_Application::getDesktop()->SetSelectionMode(ActorSelection, true);
if (theMode == 4)
mySelection->AddFilter(mySubMeshFilter);
else if (theMode == 5)
mySelection->AddFilter(myGroupFilter);
}
mySelectionMode = theMode;
}
}
//=================================================================================
// function : onApply()
// purpose :
//=================================================================================
bool SMESHGUI_GroupDlg::onApply()
{
if (!myName->text().stripWhiteSpace().isEmpty() && myElements->count() > 0) {
mySelection->ClearIObjects();
if (myGroup->_is_nil()) {
SMESH::ElementType aType = SMESH::ALL;
switch(myTypeId) {
case 0: aType = SMESH::NODE; break;
case 1: aType = SMESH::EDGE; break;
case 2: aType = SMESH::FACE; break;
case 3: aType = SMESH::VOLUME; break;
}
SMESH::long_array_var anIdList = new SMESH::long_array;
int i, k = myElements->count();
anIdList->length(k);
QListBoxItem* anItem;
for (i = 0, anItem = myElements->firstItem(); anItem != 0; i++, anItem = anItem->next()) {
anIdList[i] = anItem->text().toInt();
}
myGroup = mySMESHGUI->AddGroup(myMesh, aType, myName->text());
myGroup->Add(anIdList);
/* init for next operation */
myName->setText("");
myElements->clear();
myGroup = SMESH::SMESH_Group::_nil();
}
else {
myGroup->SetName(myName->text());
QValueList<int> aAddList;
QValueList<int>::iterator anIt;
QListBoxItem* anItem;
for (anItem = myElements->firstItem(); anItem != 0; anItem = anItem->next()) {
int anId = anItem->text().toInt();
if ((anIt = myIdList.find(anId)) == myIdList.end())
aAddList.append(anId);
else
myIdList.remove(anIt);
}
if (!aAddList.empty()) {
SMESH::long_array_var anIdList = new SMESH::long_array;
anIdList->length(aAddList.count());
int i;
for (i = 0, anIt = aAddList.begin(); anIt != aAddList.end(); anIt++, i++)
anIdList[i] = *anIt;
myGroup->Add(anIdList);
}
if (!myIdList.empty()) {
SMESH::long_array_var anIdList = new SMESH::long_array;
anIdList->length(myIdList.count());
int i;
for (i = 0, anIt = myIdList.begin(); anIt != myIdList.end(); anIt++, i++)
anIdList[i] = *anIt;
myGroup->Remove(anIdList);
}
/* init for next operation */
myIdList.clear();
for (anItem = myElements->firstItem(); anItem != 0; anItem = anItem->next())
myIdList.append(anItem->text().toInt());
}
mySMESHGUI->GetActiveStudy()->updateObjBrowser(true);
mySelection->ClearIObjects();
return true;
}
return false;
}
//=================================================================================
// function : onOK()
// purpose :
//=================================================================================
void SMESHGUI_GroupDlg::onOK()
{
if ( onApply() )
onClose();
}
//=================================================================================
// function : onClose()
// purpose :
//=================================================================================
void SMESHGUI_GroupDlg::onClose()
{
close();
}
static bool busy = false;
//=================================================================================
// function : onListSelectionChanged()
// purpose : Called when selection in element list is changed
//=================================================================================
void SMESHGUI_GroupDlg::onListSelectionChanged()
{
// MESSAGE("SMESHGUI_GroupDlg::onListSelectionChanged(); myActor = " << myActor);
if (busy || !myActor) return;
busy = true;
if (myCurrentLineEdit == 0) {
mySelection->ClearIObjects();
TColStd_MapOfInteger aIndexes;
QListBoxItem* anItem;
for (anItem = myElements->firstItem(); anItem != 0; anItem = anItem->next()) {
if (anItem->isSelected()) {
std::vector<int> aVtkList;
if (myTypeId == 0)
aVtkList = myActor->GetNodeVtkId(anItem->text().toInt());
else
aVtkList = myActor->GetElemVtkId(anItem->text().toInt());
if (aVtkList.size() > 0) {
std::vector<int>::iterator it;
for (it = aVtkList.begin(); it != aVtkList.end(); ++it) {
aIndexes.Add(*it);
}
}
}
}
mySelection->AddOrRemoveIndex(myActor->getIO(), aIndexes, false, false);
mySelection->AddIObject(myActor->getIO());
}
busy = false;
}
//=================================================================================
// function : onObjectSelectionChanged()
// purpose : Called when selection in 3D view or ObjectBrowser is changed
//=================================================================================
void SMESHGUI_GroupDlg::onObjectSelectionChanged()
{
if (busy) return;
busy = true;
int aNbSel = mySelection->IObjectCount();
myElements->clearSelection();
if (myCurrentLineEdit) {
myCurrentLineEdit->setText("") ;
QString aString = "";
if (aNbSel >= 1) {
if (aNbSel > 1) {
if (myCurrentLineEdit = mySubMeshLine)
aString = tr("SMESH_SUBMESH_SELECTED").arg(aNbSel);
else if (myCurrentLineEdit = myGroupLine)
aString = tr("SMESH_GROUP_SELECTED").arg(aNbSel);
}
else {
aString = mySelection->firstIObject()->getName();
}
}
myCurrentLineEdit->setText(aString) ;
myCurrentLineEdit->home( false );
}
else {
if (aNbSel == 1) {
QString aListStr = "";
int aNbItems = 0;
if (myTypeId == 0) {
aNbItems = mySMESHGUI->GetNameOfSelectedNodes(mySelection, aListStr);
}
else {
aNbItems = mySMESHGUI->GetNameOfSelectedElements(mySelection, aListStr);
}
if (aNbItems > 0) {
QStringList anElements = QStringList::split(" ", aListStr);
QListBoxItem* anItem = 0;
for (QStringList::iterator it = anElements.begin(); it != anElements.end(); ++it) {
anItem = myElements->findItem(*it, Qt::ExactMatch);
if (anItem) myElements->setSelected(anItem, true);
}
}
}
}
busy = false;
}
//=================================================================================
// function : onSelectSubMesh()
// purpose : Called when selection in 3D view or ObjectBrowser is changed
//=================================================================================
void SMESHGUI_GroupDlg::onSelectSubMesh(bool on)
{
if (on) {
if (mySelectGroup->isChecked()) {
mySelectGroup->setChecked(false);
}
myCurrentLineEdit = mySubMeshLine;
setSelectionMode(4);
}
else {
mySubMeshLine->setText("");
myCurrentLineEdit = 0;
if (myTypeId != -1)
setSelectionMode(myTypeId);
}
mySubMeshBtn->setEnabled(on);
mySubMeshLine->setEnabled(on);
}
//=================================================================================
// function : (onSelectGroup)
// purpose : Called when selection in 3D view or ObjectBrowser is changed
//=================================================================================
void SMESHGUI_GroupDlg::onSelectGroup(bool on)
{
if (on) {
if (mySelectSubMesh->isChecked()) {
mySelectSubMesh->setChecked(false);
}
myCurrentLineEdit = myGroupLine;
setSelectionMode(5);
}
else {
myGroupLine->setText("");
myCurrentLineEdit = 0;
if (myTypeId != -1)
setSelectionMode(myTypeId);
}
myGroupBtn->setEnabled(on);
myGroupLine->setEnabled(on);
}
//=================================================================================
// function : setCurrentSelection()
// purpose :
//=================================================================================
void SMESHGUI_GroupDlg::setCurrentSelection()
{
QPushButton* send = (QPushButton*)sender();
myCurrentLineEdit = 0;
if (send == mySubMeshBtn) {
myCurrentLineEdit = mySubMeshLine;
onObjectSelectionChanged();
}
else if (send == myGroupBtn) {
myCurrentLineEdit = myGroupLine;
onObjectSelectionChanged();
}
}
//=================================================================================
// function : setFilters()
// purpose : SLOT. Called when "Filter" button pressed.
//=================================================================================
void SMESHGUI_GroupDlg::setFilters()
{
SMESH::ElementType aType = SMESH::ALL;
switch ( myTypeId )
{
case 0 : aType = SMESH::NODE; break;
case 1 : aType = SMESH::EDGE; break;
case 2 : aType = SMESH::FACE; break;
case 3 : aType = SMESH::VOLUME; break;
default: return;
}
if ( myFilterDlg == 0 )
myFilterDlg = new SMESHGUI_FilterDlg( this, aType, true );
else
myFilterDlg->Init( aType );
myFilterDlg->SetSelection( mySelection );
myFilterDlg->SetMesh( myMesh );
myFilterDlg->SetSourceWg( myElements );
if ( myFilterDlg->exec() != QDialog::Accepted )
return;
if ( mySelectSubMesh->isChecked() || mySelectGroup->isChecked() )
{
mySelectionMode = myTypeId;
mySelectSubMesh->setChecked( false );
mySelectGroup->setChecked( false );
}
}
//=================================================================================
// function : onAdd()
// purpose :
//=================================================================================
void SMESHGUI_GroupDlg::onAdd()
{
int aNbSel = mySelection->IObjectCount();
if (aNbSel == 0) return;
busy = true;
SMESH::ElementType aType = SMESH::ALL;
switch(myTypeId) {
case 0: aType = SMESH::NODE; break;
case 1: aType = SMESH::EDGE; break;
case 2: aType = SMESH::FACE; break;
case 3: aType = SMESH::VOLUME; break;
}
if (myCurrentLineEdit == 0) {
if (aNbSel != 1) { busy = false; return; }
QString aListStr = "";
int aNbItems = 0;
if (myTypeId == 0) {
aNbItems = mySMESHGUI->GetNameOfSelectedNodes(mySelection, aListStr);
}
else {
aNbItems = mySMESHGUI->GetNameOfSelectedElements(mySelection, aListStr);
}
if (aNbItems > 0) {
QStringList anElements = QStringList::split(" ", aListStr);
QListBoxItem* anItem = 0;
for (QStringList::iterator it = anElements.begin(); it != anElements.end(); ++it) {
anItem = myElements->findItem(*it, Qt::ExactMatch);
if (!anItem) {
anItem = new QListBoxText(*it);
myElements->insertItem(anItem);
}
myElements->setSelected(anItem, true);
}
}
}
else if (myCurrentLineEdit == mySubMeshLine) {
Standard_Boolean aRes;
SALOME_ListIteratorOfListIO anIt(mySelection->StoredIObjects());
for (; anIt.More(); anIt.Next()) {
SMESH::SMESH_subMesh_var aSubMesh = mySMESHGUI->ConvertIOinSubMesh(anIt.Value(), aRes);
if (aRes && !aSubMesh->_is_nil()) {
// check if mesh is the same
if (aSubMesh->GetFather()->GetId() == myMesh->GetId()) {
if (aType == SMESH::NODE) {
try {
SMESH::long_array_var anElements = aSubMesh->GetNodesId();
int k = anElements->length();
QListBoxItem* anItem = 0;
for (int i = 0; i < k; i++) {
QString aText = QString::number(anElements[i]);
anItem = myElements->findItem(aText, Qt::ExactMatch);
if (!anItem) {
anItem = new QListBoxText(aText);
myElements->insertItem(anItem);
}
myElements->setSelected(anItem, true);
}
}
catch (const SALOME::SALOME_Exception& ex) {
QtCatchCorbaException(ex);
}
}
else {
try {
SMESH::long_array_var anElements = aSubMesh->GetElementsId();
int k = anElements->length();
QListBoxItem* anItem = 0;
for (int i = 0; i < k; i++) {
QString aText = QString::number(anElements[i]);
anItem = myElements->findItem(aText, Qt::ExactMatch);
if (!anItem) {
anItem = new QListBoxText(aText);
myElements->insertItem(anItem);
}
myElements->setSelected(anItem, true);
}
}
catch (const SALOME::SALOME_Exception& ex) {
QtCatchCorbaException(ex);
}
}
}
}
}
mySelectSubMesh->setChecked(false);
busy = false;
onListSelectionChanged();
}
else if (myCurrentLineEdit == myGroupLine) {
Standard_Boolean aRes;
SALOME_ListIteratorOfListIO anIt(mySelection->StoredIObjects());
for (; anIt.More(); anIt.Next()) {
SMESH::SMESH_Group_var aGroup = mySMESHGUI->ConvertIOinSMESHGroup(anIt.Value(), aRes);
if (aRes && !aGroup->_is_nil()) {
// check if mesh is the same
if (aGroup->GetType() == aType && aGroup->GetMesh()->GetId() == myMesh->GetId()) {
SMESH::long_array_var anElements = aGroup->GetListOfID();
int k = anElements->length();
QListBoxItem* anItem = 0;
for (int i = 0; i < k; i++) {
QString aText = QString::number(anElements[i]);
anItem = myElements->findItem(aText, Qt::ExactMatch);
if (!anItem) {
anItem = new QListBoxText(aText);
myElements->insertItem(anItem);
}
myElements->setSelected(anItem, true);
}
}
}
}
mySelectGroup->setChecked(false);
busy = false;
onListSelectionChanged();
}
busy = false;
// mySelection->ClearIObjects();
updateButtons();
}
//=================================================================================
// function : onRemove()
// purpose :
//=================================================================================
void SMESHGUI_GroupDlg::onRemove()
{
busy = true;
if (myCurrentLineEdit == 0) {
for (int i = myElements->count(); i > 0; i--) {
if (myElements->isSelected(i-1)) {
myElements->removeItem(i-1);
}
}
}
else {
int aNbSel = mySelection->IObjectCount();
if (aNbSel == 0) { busy = false; return; }
SMESH::ElementType aType = SMESH::ALL;
switch(myTypeId) {
case 0: aType = SMESH::NODE; break;
case 1: aType = SMESH::EDGE; break;
case 2: aType = SMESH::FACE; break;
case 3: aType = SMESH::VOLUME; break;
}
if (myCurrentLineEdit == mySubMeshLine) {
Standard_Boolean aRes;
SALOME_ListIteratorOfListIO anIt(mySelection->StoredIObjects());
for (; anIt.More(); anIt.Next()) {
SMESH::SMESH_subMesh_var aSubMesh = mySMESHGUI->ConvertIOinSubMesh(anIt.Value(), aRes);
if (aRes && !aSubMesh->_is_nil()) {
// check if mesh is the same
if (aSubMesh->GetFather()->GetId() == myMesh->GetId()) {
if (aType == SMESH::NODE) {
try {
SMESH::long_array_var anElements = aSubMesh->GetNodesId();
int k = anElements->length();
QListBoxItem* anItem = 0;
for (int i = 0; i < k; i++) {
anItem = myElements->findItem(QString::number(anElements[i]), Qt::ExactMatch);
if (anItem) delete anItem;
}
}
catch (const SALOME::SALOME_Exception& ex) {
QtCatchCorbaException(ex);
}
}
else {
try {
SMESH::long_array_var anElements = aSubMesh->GetElementsId();
int k = anElements->length();
QListBoxItem* anItem = 0;
for (int i = 0; i < k; i++) {
anItem = myElements->findItem(QString::number(anElements[i]), Qt::ExactMatch);
if (anItem) delete anItem;
}
}
catch (const SALOME::SALOME_Exception& ex) {
QtCatchCorbaException(ex);
}
}
}
}
}
}
else if (myCurrentLineEdit == myGroupLine) {
Standard_Boolean aRes;
SALOME_ListIteratorOfListIO anIt(mySelection->StoredIObjects());
for (; anIt.More(); anIt.Next()) {
SMESH::SMESH_Group_var aGroup = mySMESHGUI->ConvertIOinSMESHGroup(anIt.Value(), aRes);
if (aRes && !aGroup->_is_nil()) {
// check if mesh is the same
if (aGroup->GetType() == aType && aGroup->GetMesh()->GetId() == myMesh->GetId()) {
SMESH::long_array_var anElements = aGroup->GetListOfID();
int k = anElements->length();
QListBoxItem* anItem = 0;
for (int i = 0; i < k; i++) {
anItem = myElements->findItem(QString::number(anElements[i]), Qt::ExactMatch);
if (anItem) delete anItem;
}
}
}
}
}
}
busy = false;
updateButtons();
}
//=================================================================================
// function : onSort()
// purpose :
//=================================================================================
void SMESHGUI_GroupDlg::onSort()
{
// PAL5412: sorts items in ascending by "string" value
// myElements->sort(true);
// myElements->update();
int i, k = myElements->count();
if (k > 0) {
busy = true;
QStringList aSelected;
std::vector<int> anArray(k);
// QMemArray<int> anArray(k);
QListBoxItem* anItem;
// fill the array
for (anItem = myElements->firstItem(), i = 0; anItem != 0; anItem = anItem->next(), i++) {
anArray[i] = anItem->text().toInt();
if (anItem->isSelected())
aSelected.append(anItem->text());
}
// sort & update list
std::sort(anArray.begin(), anArray.end());
// anArray.sort();
myElements->clear();
for (i = 0; i < k; i++) {
myElements->insertItem(QString::number(anArray[i]));
}
for (QStringList::iterator it = aSelected.begin(); it != aSelected.end(); ++it) {
anItem = myElements->findItem(*it, Qt::ExactMatch);
if (anItem) myElements->setSelected(anItem, true);
}
busy = false;
}
}
//=================================================================================
// function : closeEvent()
// purpose :
//=================================================================================
void SMESHGUI_GroupDlg::closeEvent( QCloseEvent* e )
{
QAD_StudyFrame* aStudyFrame = mySMESHGUI->GetActiveStudy()->getActiveStudyFrame();
if (aStudyFrame->getTypeView() == VIEW_VTK) {
mySMESHGUI->SetPickable();
if (mySelectionMode == 0)
mySMESHGUI->EraseSimulationActors();
// remove filters from viewer
VTKViewer_InteractorStyleSALOME* aStyle = ((VTKViewer_ViewFrame*)aStudyFrame->getRightFrame()->getViewFrame())->getRWInteractor()->GetInteractorStyleSALOME();
aStyle->RemoveEdgeFilter();
aStyle->RemoveFaceFilter();
}
mySelection->ClearIObjects();
QAD_Application::getDesktop()->SetSelectionMode(ActorSelection);
mySelection->ClearFilters();
mySMESHGUI->ResetState();
QDialog::closeEvent( e );
}

View File

@ -0,0 +1,132 @@
// SMESH SMESHGUI : GUI for SMESH component
//
// Copyright (C) 2003 CEA
//
// 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.
//
// 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.org
//
//
//
// File : SMESHGUI_GroupDlg.h
// Author : Natalia KOPNOVA
// Module : SMESH
// $Header$
#ifndef DIALOGBOX_GROUP_H
#define DIALOGBOX_GROUP_H
#include "SALOME_Selection.h"
#include "SMESH_TypeFilter.hxx"
// QT Includes
#include <qdialog.h>
#include <qvaluelist.h>
// IDL Headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_Mesh)
#include CORBA_SERVER_HEADER(SMESH_Group)
class QLineEdit;
class QButtonGroup;
class QListBox;
class QPushButton;
class QCheckBox;
class SMESHGUI;
class SMESH_Actor;
class SMESHGUI_FilterDlg;
//=================================================================================
// class : SMESHGUI_GroupDlg
// purpose :
//=================================================================================
class SMESHGUI_GroupDlg : public QDialog
{
Q_OBJECT
public:
SMESHGUI_GroupDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* theSel = 0,
SMESH::SMESH_Mesh_ptr theMesh = SMESH::SMESH_Mesh::_nil(),
bool modal = FALSE, WFlags fl = 0 );
SMESHGUI_GroupDlg( QWidget* parent, const char* name, SALOME_Selection* theSel,
SMESH::SMESH_Group_ptr theGroup, bool modal = FALSE, WFlags fl = 0 );
~SMESHGUI_GroupDlg();
public slots:
void onAdd();
void onRemove();
private slots:
void onTypeChanged(int id);
void onOK();
void onClose();
bool onApply();
void onListSelectionChanged();
void onObjectSelectionChanged();
void onSelectSubMesh(bool on);
void onSelectGroup(bool on);
void setCurrentSelection();
void setFilters();
void onSort();
void onNameChanged(const QString& text);
private:
void initDialog(SALOME_Selection* theSel, bool create);
void init(SMESH::SMESH_Mesh_ptr theMesh);
void init(SMESH::SMESH_Group_ptr theGroup);
void closeEvent(QCloseEvent* e);
void setSelectionMode(int theMode);
void updateButtons();
SMESHGUI* mySMESHGUI ; /* Current SMESHGUI object */
SALOME_Selection* mySelection ; /* User shape selection */
SMESH_Actor* myActor; /* Current mesh actor */
int myTypeId ; /* Current type id = radio button id */
QLineEdit* myCurrentLineEdit; /* Current LineEdit */
QButtonGroup* myTypeGroup;
QLineEdit* myName;
QListBox* myElements;
QPushButton* myFilter;
QCheckBox* mySelectSubMesh;
QPushButton* mySubMeshBtn;
QLineEdit* mySubMeshLine;
QCheckBox* mySelectGroup;
QPushButton* myGroupBtn;
QLineEdit* myGroupLine;
SMESH::SMESH_Mesh_var myMesh;
SMESH::SMESH_Group_var myGroup;
QValueList<int> myIdList;
int mySelectionMode;
Handle(SMESH_TypeFilter) mySubMeshFilter;
Handle(SMESH_TypeFilter) myGroupFilter;
SMESHGUI_FilterDlg* myFilterDlg;
};
#endif // DIALOGBOX_GROUP_H

View File

@ -0,0 +1,74 @@
// SMESH SMESHGUI : GUI for SMESH component
//
// Copyright (C) 2003 CEA
//
// 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.
//
// 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.org
//
//
//
// File : SMESHGUI_Hypotheses.h
// Author : Julia DOROVSKIKH
// Module : SMESH
// $Header$
#ifndef SMESHGUI_Hypotheses_HeaderFile
#define SMESHGUI_Hypotheses_HeaderFile
#include CORBA_SERVER_HEADER(SMESH_Hypothesis)
// QT Includes
#include <qstring.h>
#include <qwidget.h>
//=================================================================================
// class : SMESHGUI_GenericHypothesisCreator
// purpose :
//=================================================================================
class SMESHGUI_GenericHypothesisCreator
{
public:
virtual void CreateHypothesis (const bool isAlgo, QWidget* parent) = 0;
virtual void EditHypothesis (SMESH::SMESH_Hypothesis_ptr theHyp) = 0;
};
//=================================================================================
// class : HypothesisData
// purpose :
//=================================================================================
class HypothesisData
{
public:
HypothesisData (const QString& aPluginName,
const QString& aServerLibName,
const QString& aClientLibName,
const QString& aLabel,
const QString& anIconId) :
PluginName(aPluginName),
ServerLibName(aServerLibName),
ClientLibName(aClientLibName),
Label(aLabel),
IconId(anIconId)
{};
QString PluginName;
QString ServerLibName;
QString ClientLibName;
QString Label;
QString IconId;
};
#endif

View File

@ -0,0 +1,307 @@
// SMESH SMESHGUI : GUI for SMESH component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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.
//
// 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.org
//
//
//
// File : SMESHGUI_Preferences_SelectionDlg.cxx
// Author : Natalia KOPNOVA
// Module : SMESH
// $Header$
using namespace std;
#include "SMESHGUI_Preferences_SelectionDlg.h"
#include "SMESHGUI.h"
#include <qgroupbox.h>
#include <qlayout.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qvalidator.h>
#include <qspinbox.h>
#include <qpushbutton.h>
#include <qpalette.h>
#include <qcolordialog.h>
//=================================================================================
// class : SMESHGUI_LineEdit
// purpose :
//=================================================================================
SMESHGUI_LineEdit::SMESHGUI_LineEdit(QWidget* parent, const char *name)
: QLineEdit(parent, name)
{
}
SMESHGUI_LineEdit::SMESHGUI_LineEdit(const QString& text, QWidget* parent, const char *name)
: QLineEdit(text, parent, name)
{
}
void SMESHGUI_LineEdit::focusOutEvent(QFocusEvent* e)
{
const QValidator* aVal = validator();
QString aText = text();
int aCurPos = cursorPosition();
if (aVal && aVal->validate(aText, aCurPos) != QValidator::Acceptable) {
QString aValid = aText;
aVal->fixup(aValid);
if (aText != aValid) {
setText(aValid);
update();
return;
}
}
QLineEdit::focusOutEvent(e);
}
//=================================================================================
// class : SMESHGUI_DoubleValidator
// purpose :
//=================================================================================
SMESHGUI_DoubleValidator::SMESHGUI_DoubleValidator(QObject * parent, const char *name)
: QDoubleValidator(parent, name)
{
}
SMESHGUI_DoubleValidator::SMESHGUI_DoubleValidator(double bottom, double top, int decimals,
QObject * parent, const char *name)
: QDoubleValidator(bottom, top, decimals, parent, name)
{
}
void SMESHGUI_DoubleValidator::fixup(QString& theText) const
{
bool ok;
double aValue = theText.toDouble(&ok);
if (ok) {
if (aValue < bottom())
theText = QString::number(bottom(), 'g', decimals());
if (aValue > top())
theText = QString::number(top(), 'g', decimals());
}
}
//=================================================================================
// class : SMESHGUI_Preferences_SelectionDlg()
// purpose :
//=================================================================================
SMESHGUI_Preferences_SelectionDlg::SMESHGUI_Preferences_SelectionDlg( QWidget* parent, const char* name )
: QDialog( parent, name, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
{
if ( !name ) setName( "SMESHGUI_Preferences_SelectionDlg" );
setCaption( tr( "SMESH_PREF_SELECTION" ) );
QVBoxLayout* aMainLayout = new QVBoxLayout(this, 11, 6);
QLabel* aLabel;
/***************************************************************/
QGroupBox* aSelectBox = new QGroupBox(4, Qt::Horizontal, this, "selection");
aSelectBox->setTitle(tr("SMESH_SELECTION"));
aLabel = new QLabel(aSelectBox, "selection color label");
aLabel->setText(tr("SMESH_OUTLINE_COLOR"));
myColor[2] = new QPushButton(aSelectBox, "outline color");
myColor[2]->setFixedSize(QSize(25, 25));
aSelectBox->addSpace(0);
aSelectBox->addSpace(0);
aLabel = new QLabel(aSelectBox, "selection color label");
aLabel->setText(tr("SMESH_ELEMENTS_COLOR"));
myColor[1] = new QPushButton(aSelectBox, "elements color");
myColor[1]->setFixedSize(QSize(25, 25));
aLabel = new QLabel(aSelectBox, "selection width label");
aLabel->setText(tr("SMESH_WIDTH"));
myWidth[1] = new QSpinBox(0, 5, 1, aSelectBox, "selection width");
myWidth[1]->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
myWidth[1]->setButtonSymbols(QSpinBox::PlusMinus);
myWidth[1]->setMinimumWidth(50);
/***************************************************************/
QGroupBox* aPreSelectBox = new QGroupBox(1, Qt::Vertical, this, "preselection");
aPreSelectBox->setTitle(tr("SMESH_PRESELECTION"));
aLabel = new QLabel(aPreSelectBox, "preselection color label");
aLabel->setText(tr("SMESH_HILIGHT_COLOR"));
myColor[0] = new QPushButton(aPreSelectBox, "preselection color");
myColor[0]->setFixedSize(QSize(25, 25));
aLabel = new QLabel(aPreSelectBox, "preselection width label");
aLabel->setText(tr("SMESH_WIDTH"));
myWidth[0] = new QSpinBox(0, 5, 1, aPreSelectBox, "preselection width");
myWidth[0]->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
myWidth[0]->setButtonSymbols(QSpinBox::PlusMinus);
myWidth[0]->setMinimumWidth(50);
/***************************************************************/
QGroupBox* aPrecisionBox = new QGroupBox(1, Qt::Vertical, this, "preselection");
aPrecisionBox->setTitle(tr("SMESH_PRECISION"));
QDoubleValidator* aValidator = new SMESHGUI_DoubleValidator(aPrecisionBox);
aValidator->setBottom(0.001);
aValidator->setDecimals(6);
aLabel = new QLabel(aPrecisionBox, "node tol label");
aLabel->setText(tr("SMESH_NODES"));
myPrecision[0] = new SMESHGUI_LineEdit(aPrecisionBox, "node precision");
myPrecision[0]->setValidator(aValidator);
aLabel = new QLabel(aPrecisionBox, "item tol label");
aLabel->setText(tr("SMESH_ELEMENTS"));
myPrecision[1] = new SMESHGUI_LineEdit(aPrecisionBox, "item precision");
myPrecision[1]->setValidator(aValidator);
/***************************************************************/
QFrame* aButtons = new QFrame(this, "button box");
aButtons->setFrameStyle(QFrame::Box | QFrame::Sunken);
QHBoxLayout* aBtnLayout = new QHBoxLayout(aButtons, 11, 6);
aBtnLayout->setAutoAdd(false);
QPushButton* aOKBtn = new QPushButton(aButtons, "ok");
aOKBtn->setText(tr("SMESH_BUT_OK"));
aOKBtn->setAutoDefault(true);
aOKBtn->setDefault(true);
QPushButton* aCloseBtn = new QPushButton(aButtons, "close");
aCloseBtn->setText(tr("SMESH_BUT_CLOSE"));
aCloseBtn->setAutoDefault(true);
aBtnLayout->addWidget(aOKBtn);
aBtnLayout->addStretch();
aBtnLayout->addWidget(aCloseBtn);
/***************************************************************/
aMainLayout->addWidget(aSelectBox);
aMainLayout->addWidget(aPreSelectBox);
aMainLayout->addWidget(aPrecisionBox);
aMainLayout->addWidget(aButtons);
for (int i = 0; i < 3; i++)
connect(myColor[i], SIGNAL(clicked()), this, SLOT(onSelectColor()));
connect(aOKBtn, SIGNAL(clicked()), this, SLOT(accept()));
connect(aCloseBtn, SIGNAL(clicked()), this, SLOT(reject()));
/* Move widget on the botton right corner of main widget */
int x, y ;
SMESHGUI::GetSMESHGUI()->DefineDlgPosition(this, x, y);
this->move(x, y);
}
//=================================================================================
// function : ~SMESHGUI_Preferences_SelectionDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
SMESHGUI_Preferences_SelectionDlg::~SMESHGUI_Preferences_SelectionDlg()
{
// no need to delete child widgets, Qt does it all for us
}
//=================================================================================
// function : closeEvent()
// purpose :
//=================================================================================
void SMESHGUI_Preferences_SelectionDlg::closeEvent( QCloseEvent* e )
{
reject();
}
//=================================================================================
// function : onSelectColor()
// purpose :
//=================================================================================
void SMESHGUI_Preferences_SelectionDlg::onSelectColor()
{
QPushButton* aSender = (QPushButton*)sender();
QColor aColor = aSender->palette().active().button();
aColor = QColorDialog::getColor(aColor, this);
if (aColor.isValid()) {
QPalette aPal = aSender->palette();
aPal.setColor(QColorGroup::Button, aColor);
aSender->setPalette(aPal);
}
}
//=================================================================================
// function : SetColor()
// purpose :
//=================================================================================
void SMESHGUI_Preferences_SelectionDlg::SetColor(int type, QColor color)
{
if (type > 0 && type <= 3) {
QPalette aPal = myColor[type-1]->palette();
aPal.setColor(QColorGroup::Button, color);
myColor[type-1]->setPalette(aPal);
}
}
//=================================================================================
// function : GetColor()
// purpose :
//=================================================================================
QColor SMESHGUI_Preferences_SelectionDlg::GetColor(int type)
{
QColor aColor;
if (type > 0 && type <= 3)
aColor = myColor[type-1]->palette().active().button();
return aColor;
}
//=================================================================================
// function : SetWidth()
// purpose :
//=================================================================================
void SMESHGUI_Preferences_SelectionDlg::SetWidth(int type, int value)
{
if (type > 0 && type <= 2)
myWidth[type-1]->setValue(value);
}
//=================================================================================
// function : GetWidth()
// purpose :
//=================================================================================
int SMESHGUI_Preferences_SelectionDlg::GetWidth(int type)
{
if (type > 0 && type <= 2)
return myWidth[type-1]->value();
return 0;
}
//=================================================================================
// function : SetPrecision()
// purpose :
//=================================================================================
void SMESHGUI_Preferences_SelectionDlg::SetPrecision(int type, double value)
{
if (type > 0 && type <= 2)
myPrecision[type-1]->setText(QString::number(value));
}
//=================================================================================
// function : GetPrecision()
// purpose :
//=================================================================================
double SMESHGUI_Preferences_SelectionDlg::GetPrecision(int type)
{
if (type > 0 && type <= 2)
return myPrecision[type-1]->text().toDouble();
}

View File

@ -0,0 +1,97 @@
// SMESH SMESHGUI : GUI for SMESH component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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.
//
// 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-platorm.org or email : webmaster.salome@opencascade.org
//
//
//
// File : SMESHGUI_Preferences_SelectionDlg.h
// Author : Natalia KOPNOVA
// Module : SMESH
// $Header$
#ifndef SMESHGUI_PREFERENCES_SELECTIONDLG_H
#define SMESHGUI_PREFERENCES_SELECTIONDLG_H
// QT Includes
#include <qdialog.h>
#include <qlineedit.h>
#include <qvalidator.h>
class QPushButton;
class QSpinBox;
class QColor;
class SMESHGUI_LineEdit : public QLineEdit
{
Q_OBJECT
public:
SMESHGUI_LineEdit(QWidget* parent, const char* name = 0);
SMESHGUI_LineEdit(const QString& text, QWidget* parent, const char* name = 0);
~SMESHGUI_LineEdit() {};
protected:
void focusOutEvent(QFocusEvent* e);
};
class SMESHGUI_DoubleValidator : public QDoubleValidator
{
Q_OBJECT
public:
SMESHGUI_DoubleValidator(QObject* parent, const char* name = 0);
SMESHGUI_DoubleValidator(double bottom, double top, int decimals,
QObject* parent, const char* name = 0);
~SMESHGUI_DoubleValidator() {};
void fixup(QString& text) const;
};
class SMESHGUI_Preferences_SelectionDlg : public QDialog
{
Q_OBJECT
public:
SMESHGUI_Preferences_SelectionDlg( QWidget* parent = 0, const char* name = 0 );
~SMESHGUI_Preferences_SelectionDlg();
void SetColor(int type, QColor color);
QColor GetColor(int type);
void SetWidth(int type, int value);
int GetWidth(int type);
void SetPrecision(int type, double value);
double GetPrecision(int type);
private:
void closeEvent( QCloseEvent* e ) ;
private slots:
void onSelectColor();
private:
QPushButton* myColor[3];
QSpinBox* myWidth[2];
QLineEdit* myPrecision[2];
};
#endif // SMESHGUI_PREFERENCES_SELECTIONDLG_H

View File

@ -0,0 +1,187 @@
// SMESH SMESHGUI : reading of xml file with list of available hypotheses and algorithms
// Copyright (C) 2003 CEA
//
// 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.
//
// 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.org
//
//
//
// File : SMESHGUI_XmlHandler.cxx
// Author : Julia DOROVSKIKH
// Module : SMESH
// $Header$
using namespace std;
#define INCLUDE_MENUITEM_DEF
#include "SMESHGUI_XmlHandler.h"
// QT Include
//#include <qaccel.h>
#include <qfileinfo.h>
/*!
Constructor
*/
SMESHGUI_XmlHandler::SMESHGUI_XmlHandler()
{
}
/*!
Destructor
*/
SMESHGUI_XmlHandler::~SMESHGUI_XmlHandler()
{
}
/*!
Starts parsing of document. Does some initialization
Reimplemented from QXmlDefaultHandler.
*/
bool SMESHGUI_XmlHandler::startDocument()
{
myErrorProt = "";
return TRUE;
}
/*!
Does different actions depending on the name of the tag and the
state you are in document.
Reimplemented from QXmlDefaultHandler.
*/
bool SMESHGUI_XmlHandler::startElement (const QString&, const QString&,
const QString& qName,
const QXmlAttributes& atts)
{
if (qName == "meshers")
{
myHypothesesMap.clear();
myAlgorithmsMap.clear();
}
else if (qName == "meshers-group") // group of hypotheses and algorithms
{
// if (atts.value("server-lib") != "")
{
myPluginName = atts.value("name");
myServerLib = atts.value("server-lib");
myClientLib = atts.value("gui-lib");
QString aResName = atts.value("resources");
if (aResName != "")
{
MESSAGE("Loading Resources " << aResName);
QAD_ResourceMgr* resMgr = QAD_Desktop::createResourceManager();
QString msg;
if (!resMgr->loadResources(aResName, msg))
MESSAGE(msg);
}
}
}
else if (qName == "hypotheses") // group of hypotheses
{
}
else if (qName == "algorithms") // group of algorithms
{
}
else if (qName == "hypothesis" || qName == "algorithm") // hypothesis or algorithm
{
if (atts.value("type") != "")
{
QString aHypAlType = atts.value("type");
QString aLabel = atts.value("label-id");
QString anIcon = atts.value("icon-id");
HypothesisData* aHypLibNames =
new HypothesisData (myPluginName, myServerLib, myClientLib,
aLabel, anIcon);
if (qName == "algorithm")
{
myAlgorithmsMap[(char*)aHypAlType.latin1()] = aHypLibNames;
}
else
{
myHypothesesMap[(char*)aHypAlType.latin1()] = aHypLibNames;
}
}
}
else
{
// error
return FALSE;
}
return TRUE;
}
/*!
Reimplemented from QXmlDefaultHandler.
*/
bool SMESHGUI_XmlHandler::endElement (const QString&, const QString&, const QString&)
{
return TRUE;
}
/*!
Reimplemented from QXmlDefaultHandler.
*/
bool SMESHGUI_XmlHandler::characters (const QString& ch)
{
// we are not interested in whitespaces
QString ch_simplified = ch.simplifyWhiteSpace();
if ( ch_simplified.isEmpty() )
return TRUE;
return TRUE;
}
/*!
Returns the default error string.
Reimplemented from QXmlDefaultHandler.
*/
QString SMESHGUI_XmlHandler::errorString()
{
return "the document is not in the quote file format";
}
/*!
Returns the error protocol if parsing failed
Reimplemented from QXmlDefaultHandler.
*/
QString SMESHGUI_XmlHandler::errorProtocol()
{
return myErrorProt;
}
/*!
Returns exception
Reimplemented from QXmlDefaultHandler.
*/
bool SMESHGUI_XmlHandler::fatalError (const QXmlParseException& exception)
{
myErrorProt += QString("fatal parsing error: %1 in line %2, column %3\n")
.arg(exception.message())
.arg(exception.lineNumber())
.arg(exception.columnNumber());
return QXmlDefaultHandler::fatalError( exception );
}

View File

@ -0,0 +1,58 @@
// SMESH SMESHGUI : reading of xml file with list of available hypotheses and algorithms
//
// Copyright (C) 2003 CEA
//
// 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.
//
// 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.org
//
//
//
// File : SMESHGUI_XmlHandler.cxx
// Author : Julia DOROVSKIKH
// Module : SMESH
// $Header$
#include "SMESHGUI.h"
#include <qxml.h>
#include <map>
class SMESHGUI_XmlHandler : public QXmlDefaultHandler
{
public:
SMESHGUI_XmlHandler();
virtual ~SMESHGUI_XmlHandler();
bool startDocument();
bool startElement( const QString& namespaceURI, const QString& localName,
const QString& qName, const QXmlAttributes& atts );
bool endElement( const QString& namespaceURI, const QString& localName, const QString& qName );
bool characters( const QString& ch );
QString errorString();
QString errorProtocol();
bool fatalError (const QXmlParseException& exception);
public:
map<string, HypothesisData*> myHypothesesMap;
map<string, HypothesisData*> myAlgorithmsMap;
private:
QString myErrorProt;
QString myPluginName;
QString myServerLib;
QString myClientLib;
};

View File

@ -0,0 +1,23 @@
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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.
//
// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
int main(int argc, char** argv)
{
return 1;
}

View File

@ -0,0 +1,914 @@
// SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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.
//
// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : SMESH_Filter_i.cxx
// Author : Alexey Petrov, OCC
// Module : SMESH
#include "SMESH_Filter_i.hxx"
#include "SMDS_Iterator.hxx"
#include "SMDS_MeshElement.hxx"
#include "SMDS_MeshNode.hxx"
#include "SMDSAbs_ElementType.hxx"
#include "SMESH_Gen_i.hxx"
#include "SMESHDS_Mesh.hxx"
#include <gp_Pnt.hxx>
#include <gp_Vec.hxx>
#include <gp_XYZ.hxx>
#include <Precision.hxx>
#include <TColgp_SequenceOfXYZ.hxx>
#include <TColStd_ListOfInteger.hxx>
#include <TColStd_MapOfInteger.hxx>
#include <TColStd_ListIteratorOfListOfInteger.hxx>
/*
AUXILIARY METHODS
*/
static inline double getAngle( const gp_XYZ& P1, const gp_XYZ& P2, const gp_XYZ& P3 )
{
return gp_Vec( P1 - P2 ).Angle( gp_Vec( P3 - P2 ) );
}
static inline double getArea( const gp_XYZ& P1, const gp_XYZ& P2, const gp_XYZ& P3 )
{
gp_Vec aVec1( P2 - P1 );
gp_Vec aVec2( P3 - P1 );
return ( aVec1 ^ aVec2 ).Magnitude() * 0.5;
}
static inline double getArea( const gp_Pnt& P1, const gp_Pnt& P2, const gp_Pnt& P3 )
{
return getArea( P1.XYZ(), P2.XYZ(), P3.XYZ() );
}
static inline double getDistance( const gp_XYZ& P1, const gp_XYZ& P2 )
{
double aDist = gp_Pnt( P1 ).Distance( gp_Pnt( P2 ) );
return aDist;
}
static int getNbMultiConnection( SMESHDS_Mesh* theMesh, const int theId )
{
if ( theMesh == 0 )
return 0;
const SMDS_MeshElement* anEdge = theMesh->FindElement( theId );
if ( anEdge == 0 || anEdge->GetType() != SMDSAbs_Edge || anEdge->NbNodes() != 2 )
return 0;
TColStd_MapOfInteger aMap;
int aResult = 0;
SMDS_ElemIteratorPtr anIter = anEdge->nodesIterator();
if ( anIter != 0 )
{
while( anIter->more() )
{
const SMDS_MeshNode* aNode = (SMDS_MeshNode*)anIter->next();
if ( aNode == 0 )
return 0;
SMDS_ElemIteratorPtr anElemIter = aNode->GetInverseElementIterator();
while( anElemIter->more() )
{
const SMDS_MeshElement* anElem = anElemIter->next();
if ( anElem != 0 && anElem->GetType() != SMDSAbs_Edge )
{
int anId = anElem->GetID();
if ( anIter->more() ) // i.e. first node
aMap.Add( anId );
else if ( aMap.Contains( anId ) )
aResult++;
}
}
// delete anElemIter;
}
// delete anIter;
}
return aResult;
}
using namespace std;
using namespace SMESH;
/*
FUNCTORS
*/
/*
Class : NumericalFunctor_i
Description : Base class for numerical functors
*/
NumericalFunctor_i::NumericalFunctor_i()
: SALOME::GenericObj_i( SMESH_Gen_i::GetPOA() )
{
myMesh = 0;
SMESH_Gen_i::GetPOA()->activate_object( this );
}
void NumericalFunctor_i::SetMesh( SMESH_Mesh_ptr theMesh )
{
SMESH_Mesh_i* anImplPtr =
dynamic_cast<SMESH_Mesh_i*>( SMESH_Gen_i::GetServant( theMesh ).in() );
myMesh = anImplPtr ? anImplPtr->GetImpl().GetMeshDS() : 0;
}
bool NumericalFunctor_i::getPoints( const int theId,
TColgp_SequenceOfXYZ& theRes ) const
{
theRes.Clear();
if ( myMesh == 0 )
return false;
// Get nodes of the face
const SMDS_MeshElement* anElem = myMesh->FindElement( theId );
if ( anElem == 0 || anElem->GetType() != GetType() )
return false;
int nbNodes = anElem->NbNodes();
SMDS_ElemIteratorPtr anIter = anElem->nodesIterator();
if ( anIter != 0 )
{
while( anIter->more() )
{
const SMDS_MeshNode* aNode = (SMDS_MeshNode*)anIter->next();
if ( aNode != 0 )
theRes.Append( gp_XYZ( aNode->X(), aNode->Y(), aNode->Z() ) );
}
// delete anIter;
}
return true;
}
/*
Class : SMESH_MinimumAngleFunct
Description : Functor for calculation of minimum angle
*/
CORBA::Double MinimumAngle_i::GetValue( CORBA::Long theId )
{
TColgp_SequenceOfXYZ P;
if ( !getPoints( theId, P ) || P.Length() != 3 && P.Length() != 4 )
return 0;
double aMin;
if ( P.Length() == 3 )
{
double A0 = getAngle( P( 3 ), P( 1 ), P( 2 ) );
double A1 = getAngle( P( 1 ), P( 2 ), P( 3 ) );
double A2 = getAngle( P( 2 ), P( 3 ), P( 1 ) );
aMin = Min( A0, Min( A1, A2 ) );
}
else
{
double A0 = getAngle( P( 4 ), P( 1 ), P( 2 ) );
double A1 = getAngle( P( 1 ), P( 2 ), P( 3 ) );
double A2 = getAngle( P( 2 ), P( 3 ), P( 4 ) );
double A3 = getAngle( P( 3 ), P( 4 ), P( 1 ) );
aMin = Min( Min( A0, A1 ), Min( A2, A3 ) );
}
return aMin * 180 / PI;
}
int MinimumAngle_i::GetType() const
{
return SMDSAbs_Face;
}
/*
Class : AspectRatio_i
Description : Functor for calculating aspect ratio
*/
CORBA::Double AspectRatio_i::GetValue( CORBA::Long theId )
{
TColgp_SequenceOfXYZ P;
if ( !getPoints( theId, P ) || P.Length() != 3 && P.Length() != 4 )
return 0;
int nbNodes = P.Length();
// Compute lengths of the sides
double aLen[ nbNodes ];
for ( int i = 0; i < nbNodes - 1; i++ )
aLen[ i ] = getDistance( P( i + 1 ), P( i + 2 ) );
aLen[ nbNodes - 1 ] = getDistance( P( 1 ), P( nbNodes ) );
// Compute aspect ratio
if ( nbNodes == 3 )
{
double aMaxLen = Max( aLen[ 0 ], Max( aLen[ 1 ], aLen[ 2 ] ) );
double anArea = getArea( P( 1 ), P( 2 ), P( 3 ) );
static double aCoef = sqrt( 3. ) / 4;
return anArea != 0 ? aCoef * aMaxLen * aMaxLen / anArea : 0;
}
else
{
double aMaxLen = Max( Max( aLen[ 0 ], aLen[ 1 ] ), Max( aLen[ 2 ], aLen[ 3 ] ) );
double aMinLen = Min( Min( aLen[ 0 ], aLen[ 1 ] ), Min( aLen[ 2 ], aLen[ 3 ] ) );
return aMinLen != 0 ? aMaxLen / aMinLen : 0;
}
}
int AspectRatio_i::GetType() const
{
return SMDSAbs_Face;
}
/*
Class : Warping_i
Description : Functor for calculating warping
*/
CORBA::Double Warping_i::GetValue( CORBA::Long theId )
{
TColgp_SequenceOfXYZ P;
if ( !getPoints( theId, P ) || P.Length() != 4 )
return 0;
gp_XYZ G = ( P( 1 ) + P( 2 ) + P( 3 ) + P( 4 ) ) / 4;
double A1 = ComputeA( P( 1 ), P( 2 ), P( 3 ), G );
double A2 = ComputeA( P( 2 ), P( 3 ), P( 4 ), G );
double A3 = ComputeA( P( 3 ), P( 4 ), P( 1 ), G );
double A4 = ComputeA( P( 4 ), P( 1 ), P( 2 ), G );
return Max( Max( A1, A2 ), Max( A3, A4 ) );
}
double Warping_i::ComputeA( const gp_XYZ& thePnt1,
const gp_XYZ& thePnt2,
const gp_XYZ& thePnt3,
const gp_XYZ& theG ) const
{
double aLen1 = gp_Pnt( thePnt1 ).Distance( gp_Pnt( thePnt2 ) );
double aLen2 = gp_Pnt( thePnt2 ).Distance( gp_Pnt( thePnt3 ) );
double L = Min( aLen1, aLen2 ) * 0.5;
gp_XYZ GI = ( thePnt2 - thePnt1 ) / 2. - theG;
gp_XYZ GJ = ( thePnt3 - thePnt2 ) / 2. - theG;
gp_XYZ N = GI.Crossed( GJ );
N.Normalize();
double H = gp_Vec( thePnt2 - theG ).Dot( gp_Vec( N ) );
return asin( fabs( H / L ) ) * 180 / PI;
}
int Warping_i::GetType() const
{
return SMDSAbs_Face;
}
/*
Class : Taper_i
Description : Functor for calculating taper
*/
CORBA::Double Taper_i::GetValue( CORBA::Long theId )
{
TColgp_SequenceOfXYZ P;
if ( !getPoints( theId, P ) || P.Length() != 4 )
return 0;
// Compute taper
double J1 = getArea( P( 4 ), P( 1 ), P( 2 ) ) / 2;
double J2 = getArea( P( 3 ), P( 1 ), P( 2 ) ) / 2;
double J3 = getArea( P( 2 ), P( 3 ), P( 4 ) ) / 2;
double J4 = getArea( P( 3 ), P( 4 ), P( 1 ) ) / 2;
double JA = 0.25 * ( J1 + J2 + J3 + J4 );
double T1 = fabs( ( J1 - JA ) / JA );
double T2 = fabs( ( J2 - JA ) / JA );
double T3 = fabs( ( J3 - JA ) / JA );
double T4 = fabs( ( J4 - JA ) / JA );
return Max( Max( T1, T2 ), Max( T3, T4 ) );
}
int Taper_i::GetType() const
{
return SMDSAbs_Face;
}
/*
Class : Skew_i
Description : Functor for calculating skew in degrees
*/
static inline double skewAngle( const gp_XYZ& p1, const gp_XYZ& p2, const gp_XYZ& p3 )
{
gp_XYZ p12 = ( p2 + p1 ) / 2;
gp_XYZ p23 = ( p3 + p2 ) / 2;
gp_XYZ p31 = ( p3 + p1 ) / 2;
return gp_Vec( p31 - p2 ).Angle( p12 - p23 );
}
CORBA::Double Skew_i::GetValue( CORBA::Long theId )
{
TColgp_SequenceOfXYZ P;
if ( !getPoints( theId, P ) || P.Length() != 3 && P.Length() != 4 )
return 0;
// Compute skew
static double PI2 = PI / 2;
if ( P.Length() == 3 )
{
double A0 = fabs( PI2 - skewAngle( P( 3 ), P( 1 ), P( 2 ) ) );
double A1 = fabs( PI2 - skewAngle( P( 1 ), P( 2 ), P( 3 ) ) );
double A2 = fabs( PI2 - skewAngle( P( 2 ), P( 3 ), P( 1 ) ) );
return Max( A0, Max( A1, A2 ) ) * 180 / PI;
}
else
{
gp_XYZ p12 = ( P( 1 ) + P( 2 ) ) / 2;
gp_XYZ p23 = ( P( 2 ) + P( 3 ) ) / 2;
gp_XYZ p34 = ( P( 3 ) + P( 4 ) ) / 2;
gp_XYZ p41 = ( P( 4 ) + P( 1 ) ) / 2;
double A = fabs( PI2 - gp_Vec( p34 - p12 ).Angle( p23 - p41 ) );
return A * 180 / PI;
}
}
int Skew_i::GetType() const
{
return SMDSAbs_Face;
}
/*
Class : Area_i
Description : Functor for calculating area
*/
CORBA::Double Area_i::GetValue( CORBA::Long theId )
{
TColgp_SequenceOfXYZ P;
if ( !getPoints( theId, P ) || P.Length() != 3 && P.Length() != 4 )
return 0;
if ( P.Length() == 3 )
return getArea( P( 1 ), P( 2 ), P( 3 ) );
else
return getArea( P( 1 ), P( 2 ), P( 3 ) ) + getArea( P( 1 ), P( 3 ), P( 4 ) );
}
int Area_i::GetType() const
{
return SMDSAbs_Face;
}
/*
Class : Length_i
Description : Functor for calculating length off edge
*/
CORBA::Double Length_i::GetValue( CORBA::Long theId )
{
TColgp_SequenceOfXYZ P;
return getPoints( theId, P ) && P.Length() == 2 ? getDistance( P( 1 ), P( 2 ) ) : 0;
}
int Length_i::GetType() const
{
return SMDSAbs_Edge;
}
/*
Class : MultiConnection_i
Description : Functor for calculating number of faces conneted to the edge
*/
CORBA::Double MultiConnection_i::GetValue( CORBA::Long theId )
{
return getNbMultiConnection( myMesh, theId );
}
int MultiConnection_i::GetType() const
{
return SMDSAbs_Edge;
}
/*
PREDICATES
*/
/*
Class : Predicate_i
Description : Base class for all predicates
*/
Predicate_i::Predicate_i()
: SALOME::GenericObj_i( SMESH_Gen_i::GetPOA() )
{
SMESH_Gen_i::GetPOA()->activate_object( this );
}
/*
Class : FreeBorders_i
Description : Predicate for free borders
*/
FreeBorders_i::FreeBorders_i()
{
myMesh = 0;
}
void FreeBorders_i::SetMesh( SMESH_Mesh_ptr theMesh )
{
SMESH_Mesh_i* anImplPtr =
dynamic_cast<SMESH_Mesh_i*>( SMESH_Gen_i::GetServant( theMesh ).in() );
myMesh = anImplPtr ? anImplPtr->GetImpl().GetMeshDS() : 0;
}
CORBA::Boolean FreeBorders_i::IsSatisfy( CORBA::Long theId )
{
return getNbMultiConnection( myMesh, theId ) == 1;
}
int FreeBorders_i::GetType() const
{
return SMDSAbs_Edge;
}
/*
Class : Comparator_i
Description : Base class for comparators
*/
Comparator_i::Comparator_i()
{
myMargin = 0;
myFunctor = 0;
}
Comparator_i::~Comparator_i()
{
if ( myFunctor != 0 )
myFunctor->Destroy();
}
void Comparator_i::SetMesh( SMESH_Mesh_ptr theMesh )
{
if ( myFunctor != 0 )
myFunctor->SetMesh( theMesh );
}
void Comparator_i::SetMargin( CORBA::Double theValue )
{
myMargin = theValue;
}
void Comparator_i::SetNumFunctor( NumericalFunctor_ptr theFunct )
{
if ( myFunctor != 0 )
myFunctor->Destroy();
myFunctor = dynamic_cast<NumericalFunctor_i*>( SMESH_Gen_i::GetServant( theFunct ).in() );
if ( myFunctor != 0 )
myFunctor->Register();
}
int Comparator_i::GetType() const
{
return myFunctor != 0 ? myFunctor->GetType() : SMDSAbs_All;
}
/*
Class : LessThan_i
Description : Comparator "<"
*/
CORBA::Boolean LessThan_i::IsSatisfy( CORBA::Long theId )
{
return myFunctor != 0 && myFunctor->GetValue( theId ) < myMargin;
}
/*
Class : MoreThan_i
Description : Comparator ">"
*/
CORBA::Boolean MoreThan_i::IsSatisfy( CORBA::Long theId )
{
return myFunctor != 0 && myFunctor->GetValue( theId ) > myMargin;
}
/*
Class : EqualTo_i
Description : Comparator "="
*/
EqualTo_i::EqualTo_i()
{
myToler = Precision::Confusion();
}
CORBA::Boolean EqualTo_i::IsSatisfy( CORBA::Long theId )
{
return myFunctor != 0 && fabs( myFunctor->GetValue( theId ) - myMargin ) < myToler;
}
void EqualTo_i::SetTolerance( CORBA::Double theToler )
{
myToler = theToler;
}
/*
Class : LogicalNOT_i
Description : Logical NOT predicate
*/
LogicalNOT_i::LogicalNOT_i()
{
myPredicate = 0;
}
LogicalNOT_i::~LogicalNOT_i()
{
if ( myPredicate )
myPredicate->Destroy();
}
CORBA::Boolean LogicalNOT_i::IsSatisfy( CORBA::Long theId )
{
return myPredicate !=0 && !myPredicate->IsSatisfy( theId );
}
void LogicalNOT_i::SetMesh( SMESH_Mesh_ptr theMesh )
{
if ( myPredicate != 0 )
myPredicate->SetMesh( theMesh );
}
void LogicalNOT_i::SetPredicate( Predicate_ptr thePred )
{
if ( myPredicate != 0 )
myPredicate->Destroy();
myPredicate = dynamic_cast<Predicate_i*>( SMESH_Gen_i::GetServant( thePred ).in() );
if ( myPredicate != 0 )
myPredicate->Register();
}
int LogicalNOT_i::GetType() const
{
return myPredicate != 0 ? myPredicate->GetType() : SMDSAbs_All;
}
/*
Class : LogicalBinary_i
Description : Base class for binary logical predicate
*/
LogicalBinary_i::LogicalBinary_i()
{
myPredicate1 = 0;
myPredicate2 = 0;
}
LogicalBinary_i::~LogicalBinary_i()
{
if ( myPredicate1 != 0 )
myPredicate1->Destroy();
if ( myPredicate2 != 0 )
myPredicate2->Destroy();
}
void LogicalBinary_i::SetMesh( SMESH_Mesh_ptr theMesh )
{
if ( myPredicate1 != 0 )
myPredicate1->SetMesh( theMesh );
if ( myPredicate2 != 0 )
myPredicate2->SetMesh( theMesh );
}
void LogicalBinary_i::SetPredicate1( Predicate_ptr thePredicate )
{
if ( myPredicate1 != 0 )
myPredicate1->Destroy();
myPredicate1 = dynamic_cast<Predicate_i*>( SMESH_Gen_i::GetServant( thePredicate ).in() );
if ( myPredicate1 != 0 )
myPredicate1->Register();
}
void LogicalBinary_i::SetPredicate2( Predicate_ptr thePredicate )
{
if ( myPredicate2 != 0 )
myPredicate2->Destroy();
myPredicate2 = dynamic_cast<Predicate_i*>( SMESH_Gen_i::GetServant( thePredicate ).in() );
if ( myPredicate2 != 0 )
myPredicate2->Register();
}
int LogicalBinary_i::GetType() const
{
if ( myPredicate1 == 0 || myPredicate2 == 0 )
return SMDSAbs_All;
int aType1 = myPredicate1->GetType();
int aType2 = myPredicate2->GetType();
return aType1 == aType2 ? aType1 : SMDSAbs_All;
}
/*
Class : LogicalAND_i
Description : Logical AND
*/
CORBA::Boolean LogicalAND_i::IsSatisfy( CORBA::Long theId )
{
return myPredicate1 != 0 &&
myPredicate2 != 0 &&
myPredicate1->IsSatisfy( theId ) && myPredicate2->IsSatisfy( theId );;
}
/*
Class : LogicalOR_i
Description : Logical OR
*/
CORBA::Boolean LogicalOR_i::IsSatisfy( CORBA::Long theId )
{
return myPredicate1 != 0 &&
myPredicate2 != 0 &&
myPredicate1->IsSatisfy( theId ) || myPredicate2->IsSatisfy( theId );
}
/*
FILTER
*/
Filter_i::Filter_i()
{
myPredicate = 0;
}
Filter_i::~Filter_i()
{
if ( myPredicate != 0 )
myPredicate->Destroy();
}
void Filter_i::SetPredicate( Predicate_ptr thePredicate )
{
if ( myPredicate != 0 )
myPredicate->Destroy();
myPredicate = dynamic_cast<Predicate_i*>( SMESH_Gen_i::GetServant( thePredicate ).in() );
if ( myPredicate != 0 )
myPredicate->Register();
}
void Filter_i::SetMesh( SMESH_Mesh_ptr theMesh )
{
if ( myPredicate != 0 )
myPredicate->SetMesh( theMesh );
}
SMESH::long_array* Filter_i::GetElementsId( SMESH_Mesh_ptr theMesh )
{
SetMesh( theMesh );
SMESH_Mesh_i* anImplPtr =
dynamic_cast<SMESH_Mesh_i*>( SMESH_Gen_i::GetServant( theMesh ).in() );
TColStd_ListOfInteger aList;
if ( anImplPtr != 0 )
{
SMESHDS_Mesh* aMesh = anImplPtr->GetImpl().GetMeshDS();
if ( myPredicate != 0 )
{
int aType = myPredicate->GetType();
if ( aType == SMDSAbs_Edge )
{
SMDS_EdgeIteratorPtr anIter = aMesh->edgesIterator();
if ( anIter != 0 )
{
while( anIter->more() )
{
const SMDS_MeshElement* anElem = anIter->next();
if ( myPredicate->IsSatisfy( anElem->GetID() ) )
aList.Append( anElem->GetID() );
}
}
// delete anIter;
}
else if ( aType == SMDSAbs_Face )
{
SMDS_FaceIteratorPtr anIter = aMesh->facesIterator();
if ( anIter != 0 )
{
while( anIter->more() )
{
const SMDS_MeshElement* anElem = anIter->next();
if ( myPredicate->IsSatisfy( anElem->GetID() ) )
aList.Append( anElem->GetID() );
}
}
// delete anIter;
}
}
}
SMESH::long_array_var anArray = new SMESH::long_array;
anArray->length( aList.Extent() );
TColStd_ListIteratorOfListOfInteger anIter( aList );
int i = 0;
for( ; anIter.More(); anIter.Next() )
anArray[ i++ ] = anIter.Value();
return anArray._retn();
}
/*
FILTER MANAGER
*/
FilterManager_i::FilterManager_i()
: SALOME::GenericObj_i( SMESH_Gen_i::GetPOA() )
{
SMESH_Gen_i::GetPOA()->activate_object( this );
}
MinimumAngle_ptr FilterManager_i::CreateMinimumAngle()
{
SMESH::MinimumAngle_i* aServant = new SMESH::MinimumAngle_i();
SMESH::MinimumAngle_var anObj = aServant->_this();
return anObj._retn();
}
AspectRatio_ptr FilterManager_i::CreateAspectRatio()
{
SMESH::AspectRatio_i* aServant = new SMESH::AspectRatio_i();
SMESH::AspectRatio_var anObj = aServant->_this();
return anObj._retn();
}
Warping_ptr FilterManager_i::CreateWarping()
{
SMESH::Warping_i* aServant = new SMESH::Warping_i();
SMESH::Warping_var anObj = aServant->_this();
return anObj._retn();
}
Taper_ptr FilterManager_i::CreateTaper()
{
SMESH::Taper_i* aServant = new SMESH::Taper_i();
SMESH::Taper_var anObj = aServant->_this();
return anObj._retn();
}
Skew_ptr FilterManager_i::CreateSkew()
{
SMESH::Skew_i* aServant = new SMESH::Skew_i();
SMESH::Skew_var anObj = aServant->_this();
return anObj._retn();
}
Area_ptr FilterManager_i::CreateArea()
{
SMESH::Area_i* aServant = new SMESH::Area_i();
SMESH::Area_var anObj = aServant->_this();
return anObj._retn();
}
Length_ptr FilterManager_i::CreateLength()
{
SMESH::Length_i* aServant = new SMESH::Length_i();
SMESH::Length_var anObj = aServant->_this();
return anObj._retn();
}
MultiConnection_ptr FilterManager_i::CreateMultiConnection()
{
SMESH::MultiConnection_i* aServant = new SMESH::MultiConnection_i();
SMESH::MultiConnection_var anObj = aServant->_this();
return anObj._retn();
}
FreeBorders_ptr FilterManager_i::CreateFreeBorders()
{
SMESH::FreeBorders_i* aServant = new SMESH::FreeBorders_i();
SMESH::FreeBorders_var anObj = aServant->_this();
return anObj._retn();
}
LessThan_ptr FilterManager_i::CreateLessThan()
{
SMESH::LessThan_i* aServant = new SMESH::LessThan_i();
SMESH::LessThan_var anObj = aServant->_this();
return anObj._retn();
}
MoreThan_ptr FilterManager_i::CreateMoreThan()
{
SMESH::MoreThan_i* aServant = new SMESH::MoreThan_i();
SMESH::MoreThan_var anObj = aServant->_this();
return anObj._retn();
}
EqualTo_ptr FilterManager_i::CreateEqualTo()
{
SMESH::EqualTo_i* aServant = new SMESH::EqualTo_i();
SMESH::EqualTo_var anObj = aServant->_this();
return anObj._retn();
}
LogicalNOT_ptr FilterManager_i::CreateLogicalNOT()
{
SMESH::LogicalNOT_i* aServant = new SMESH::LogicalNOT_i();
SMESH::LogicalNOT_var anObj = aServant->_this();
return anObj._retn();
}
LogicalAND_ptr FilterManager_i::CreateLogicalAND()
{
SMESH::LogicalAND_i* aServant = new SMESH::LogicalAND_i();
SMESH::LogicalAND_var anObj = aServant->_this();
return anObj._retn();
}
LogicalOR_ptr FilterManager_i::CreateLogicalOR()
{
SMESH::LogicalOR_i* aServant = new SMESH::LogicalOR_i();
SMESH::LogicalOR_var anObj = aServant->_this();
return anObj._retn();
}
Filter_ptr FilterManager_i::CreateFilter()
{
SMESH::Filter_i* aServant = new SMESH::Filter_i();
SMESH::Filter_var anObj = aServant->_this();
return anObj._retn();
}

View File

@ -0,0 +1,417 @@
// SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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.
//
// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : SMESH_Filter_i.hxx
// Author : Alexey Petrov, OCC
// Module : SMESH
#ifndef _SMESH_FILTER_I_HXX_
#define _SMESH_FILTER_I_HXX_
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_Filter)
#include "SALOME_GenericObj_i.hh"
class SMESHDS_Mesh;
class gp_Pnt;
class gp_XYZ;
class TColgp_SequenceOfXYZ;
namespace SMESH{
/*
FUNCTORS
*/
/*
Class : NumericalFunctor_i
Description : Base class for numerical functors
PortableServer::POA_ptr thePOA
*/
class NumericalFunctor_i: public virtual POA_SMESH::NumericalFunctor,
public virtual SALOME::GenericObj_i
{
public:
NumericalFunctor_i();
void SetMesh( SMESH_Mesh_ptr theMesh );
virtual int GetType() const = 0;
protected:
bool getPoints( const int theId,
TColgp_SequenceOfXYZ& theRes ) const;
protected:
SMESHDS_Mesh* myMesh;
};
/*
Class : SMESH_MinimumAngleFunct
Description : Functor for calculation of minimum angle
*/
class MinimumAngle_i: public virtual POA_SMESH::MinimumAngle,
public virtual NumericalFunctor_i
{
public:
CORBA::Double GetValue( CORBA::Long theElementId );
virtual int GetType() const;
};
/*
Class : AspectRatio_i
Description : Functor for calculating aspect ratio
*/
class AspectRatio_i: public virtual POA_SMESH::AspectRatio,
public virtual NumericalFunctor_i
{
public:
CORBA::Double GetValue(CORBA::Long theElementId);
virtual int GetType() const;
};
/*
Class : Warping_i
Description : Functor for calculating warping
*/
class Warping_i: public virtual POA_SMESH::Warping,
public virtual NumericalFunctor_i
{
public:
CORBA::Double GetValue(CORBA::Long theElementId);
virtual int GetType() const;
private:
double ComputeA( const gp_XYZ&, const gp_XYZ&,
const gp_XYZ&, const gp_XYZ& ) const;
};
/*
Class : Taper_i
Description : Functor for calculating taper
*/
class Taper_i: public virtual POA_SMESH::Taper,
public virtual NumericalFunctor_i
{
public:
CORBA::Double GetValue( CORBA::Long theElementId );
virtual int GetType() const;
};
/*
Class : Skew_i
Description : Functor for calculating skew in degrees
*/
class Skew_i: public virtual POA_SMESH::Skew,
public virtual NumericalFunctor_i
{
public:
CORBA::Double GetValue( CORBA::Long theElementId );
virtual int GetType() const;
};
/*
Class : Area_i
Description : Functor for calculating area
*/
class Area_i: public virtual POA_SMESH::Area,
public virtual NumericalFunctor_i
{
public:
CORBA::Double GetValue( CORBA::Long theElementId );
virtual int GetType() const;
};
/*
Class : Length_i
Description : Functor for calculating length of edge
*/
class Length_i: public virtual POA_SMESH::Length,
public virtual NumericalFunctor_i
{
public:
CORBA::Double GetValue( CORBA::Long theElementId );
virtual int GetType() const;
};
/*
Class : MultiConnection_i
Description : Functor for calculating number of faces conneted to the edge
*/
class MultiConnection_i: public virtual POA_SMESH::MultiConnection,
public virtual NumericalFunctor_i
{
public:
CORBA::Double GetValue( CORBA::Long theElementId );
virtual int GetType() const;
};
/*
PREDICATES
*/
/*
Class : Predicate_i
Description : Base class for all predicates
*/
class Predicate_i: public virtual POA_SMESH::Predicate,
public virtual SALOME::GenericObj_i
{
public:
Predicate_i();
virtual int GetType() const = 0;
};
/*
Class : FreeBorders_i
Description : Predicate for free borders
*/
class FreeBorders_i: public virtual POA_SMESH::FreeBorders,
public virtual Predicate_i
{
public:
FreeBorders_i();
void SetMesh( SMESH_Mesh_ptr theMesh );
CORBA::Boolean IsSatisfy( CORBA::Long theElementId );
virtual int GetType() const;
protected:
SMESHDS_Mesh* myMesh;
};
/*
Class : Comparator_i
Description : Base class for comparators
*/
class Comparator_i: public virtual POA_SMESH::Comparator,
public virtual Predicate_i
{
public:
Comparator_i();
virtual ~Comparator_i();
void SetMesh( SMESH_Mesh_ptr theMesh );
void SetMargin( CORBA::Double );
void SetNumFunctor( NumericalFunctor_ptr );
virtual int GetType() const;
protected:
CORBA::Double myMargin;
NumericalFunctor_i* myFunctor;
};
/*
Class : LessThan_i
Description : Comparator "<"
*/
class LessThan_i: public virtual POA_SMESH::LessThan,
public virtual Comparator_i
{
public:
CORBA::Boolean IsSatisfy( CORBA::Long theElementId );
};
/*
Class : MoreThan_i
Description : Comparator ">"
*/
class MoreThan_i: public virtual POA_SMESH::MoreThan,
public virtual Comparator_i
{
public:
CORBA::Boolean IsSatisfy( CORBA::Long theElementId );
};
/*
Class : EqualTo_i
Description : Comparator "="
*/
class EqualTo_i: public virtual POA_SMESH::EqualTo,
public virtual Comparator_i
{
public:
EqualTo_i();
CORBA::Boolean IsSatisfy( CORBA::Long theElementId );
void SetTolerance( CORBA::Double );
private:
CORBA::Double myToler;
};
/*
Class : Logical_i
Description : Base class for logical predicate
*/
class Logical_i: public virtual POA_SMESH::Logical,
public virtual Predicate_i
{
};
/*
Class : LogicalNOT_i
Description : Logical NOT predicate
*/
class LogicalNOT_i: public virtual POA_SMESH::LogicalNOT,
public virtual Logical_i
{
public:
LogicalNOT_i();
virtual ~LogicalNOT_i();
CORBA::Boolean IsSatisfy( CORBA::Long );
void SetMesh( SMESH_Mesh_ptr );
void SetPredicate( Predicate_ptr );
virtual int GetType() const;
private:
Predicate_i* myPredicate;
};
/*
Class : LogicalBinary_i
Description : Base class for binary logical predicate
*/
class LogicalBinary_i: public virtual POA_SMESH::LogicalBinary,
public virtual Logical_i
{
public:
LogicalBinary_i();
virtual ~LogicalBinary_i();
void SetMesh( SMESH_Mesh_ptr );
void SetPredicate1( Predicate_ptr );
void SetPredicate2( Predicate_ptr );
virtual int GetType() const;
protected:
Predicate_i* myPredicate1;
Predicate_i* myPredicate2;
};
/*
Class : LogicalAND_i
Description : Logical AND
*/
class LogicalAND_i: public virtual POA_SMESH::LogicalAND,
public virtual LogicalBinary_i
{
public:
CORBA::Boolean IsSatisfy( CORBA::Long theElementId );
};
/*
Class : LogicalOR_i
Description : Logical OR
*/
class LogicalOR_i: public virtual POA_SMESH::LogicalOR,
public virtual LogicalBinary_i
{
public:
CORBA::Boolean IsSatisfy( CORBA::Long theElementId );
};
/*
FILTER
*/
class Filter_i: public virtual POA_SMESH::Filter,
public virtual SALOME::GenericObj_i
{
public:
Filter_i();
virtual ~Filter_i();
void SetPredicate(Predicate_ptr );
long_array* GetElementsId(SMESH_Mesh_ptr );
void SetMesh( SMESH_Mesh_ptr );
protected:
Predicate_i* myPredicate;
};
/*
FILTER MANAGER
*/
class FilterManager_i: public virtual POA_SMESH::FilterManager,
public virtual SALOME::GenericObj_i
{
public:
FilterManager_i();
MinimumAngle_ptr CreateMinimumAngle();
AspectRatio_ptr CreateAspectRatio();
Warping_ptr CreateWarping();
Taper_ptr CreateTaper();
Skew_ptr CreateSkew();
Area_ptr CreateArea();
Length_ptr CreateLength();
MultiConnection_ptr CreateMultiConnection();
FreeBorders_ptr CreateFreeBorders();
LessThan_ptr CreateLessThan();
MoreThan_ptr CreateMoreThan();
EqualTo_ptr CreateEqualTo();
LogicalNOT_ptr CreateLogicalNOT();
LogicalAND_ptr CreateLogicalAND();
LogicalOR_ptr CreateLogicalOR();
Filter_ptr CreateFilter();
};
};
#endif

View File

@ -0,0 +1,358 @@
// SMESH SMESH_I : idl implementation based on 'SMESH' unit's classes
//
// Copyright (C) 2004 CEA
//
// 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.
//
// 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.org
//
//
//
// File : SMESH_Group_i.cxx
// Author : Sergey ANIKIN, OCC
// Module : SMESH
// $Header$
#include "SMESH_Group_i.hxx"
#include "SMESH_Mesh_i.hxx"
#include "SMESH_Gen_i.hxx"
#include <SMESH_Group.hxx>
#include <SMESHDS_Group.hxx>
#include <SMDSAbs_ElementType.hxx>
#include <utilities.h>
//=============================================================================
/*!
*
*/
//=============================================================================
SMESH_Group_i::SMESH_Group_i( PortableServer::POA_ptr thePOA, SMESH_Mesh_i* theMeshServant, const int theLocalID )
: SALOME::GenericObj_i( thePOA ),
myMeshServant( theMeshServant ),
myLocalID( theLocalID )
{
thePOA->activate_object( this );
}
//=============================================================================
/*!
*
*/
//=============================================================================
SMESH_Group_i::~SMESH_Group_i()
{
MESSAGE("~SMESH_Group_i;" );
if ( myMeshServant )
myMeshServant->removeGroup(myLocalID);
}
//=============================================================================
/*!
*
*/
//=============================================================================
void SMESH_Group_i::SetName( const char* theName )
{
if ( myMeshServant ) {
::SMESH_Mesh& aMesh = myMeshServant->GetImpl();
::SMESH_Group* aGroup = aMesh.GetGroup(myLocalID);
if (aGroup) {
aGroup->SetName(theName);
// Update group name in a study
SALOMEDS::Study_var aStudy = myMeshServant->GetGen()->GetCurrentStudy();
if ( !aStudy->_is_nil() ) {
SALOMEDS::SObject_var aGroupSO = aStudy->FindObjectIOR( SMESH_Gen_i::GetORB()->object_to_string( _this() ) );
if ( !aGroupSO->_is_nil() ) {
SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
aBuilder->SetName( aGroupSO, theName );
}
}
return;
}
}
MESSAGE("can't set name of a vague group");
}
//=============================================================================
/*!
*
*/
//=============================================================================
char* SMESH_Group_i::GetName()
{
if ( myMeshServant ) {
::SMESH_Mesh& aMesh = myMeshServant->GetImpl();
::SMESH_Group* aGroup = aMesh.GetGroup(myLocalID);
if (aGroup)
return CORBA::string_dup (aGroup->GetName());
}
MESSAGE("get name of a vague group");
return CORBA::string_dup( "NO_NAME" );
}
//=============================================================================
/*!
*
*/
//=============================================================================
SMESH::ElementType SMESH_Group_i::GetType()
{
if ( myMeshServant ) {
::SMESH_Mesh& aMesh = myMeshServant->GetImpl();
::SMESH_Group* aGroup = aMesh.GetGroup(myLocalID);
if (aGroup) {
SMDSAbs_ElementType aSMDSType = aGroup->GetGroupDS()->GetType();
SMESH::ElementType aType;
switch (aSMDSType) {
case SMDSAbs_Node: aType = SMESH::NODE; break;
case SMDSAbs_Edge: aType = SMESH::EDGE; break;
case SMDSAbs_Face: aType = SMESH::FACE; break;
case SMDSAbs_Volume: aType = SMESH::VOLUME; break;
default: aType = SMESH::ALL; break;
}
return aType;
}
}
MESSAGE("get type of a vague group");
return SMESH::ALL;
}
//=============================================================================
/*!
*
*/
//=============================================================================
CORBA::Long SMESH_Group_i::Size()
{
if ( myMeshServant ) {
::SMESH_Mesh& aMesh = myMeshServant->GetImpl();
::SMESH_Group* aGroup = aMesh.GetGroup(myLocalID);
if (aGroup) {
int aSize = aGroup->GetGroupDS()->Extent();
return aSize;
}
}
MESSAGE("get size of a vague group");
return 0;
}
//=============================================================================
/*!
*
*/
//=============================================================================
CORBA::Boolean SMESH_Group_i::IsEmpty()
{
if ( myMeshServant ) {
::SMESH_Mesh& aMesh = myMeshServant->GetImpl();
::SMESH_Group* aGroup = aMesh.GetGroup(myLocalID);
if (aGroup) {
bool isEmpty = aGroup->GetGroupDS()->IsEmpty();
return isEmpty;
}
}
MESSAGE("checking IsEmpty of a vague group");
return true;
}
//=============================================================================
/*!
*
*/
//=============================================================================
void SMESH_Group_i::Clear()
{
if ( myMeshServant ) {
::SMESH_Mesh& aMesh = myMeshServant->GetImpl();
::SMESH_Group* aGroup = aMesh.GetGroup(myLocalID);
if (aGroup) {
// a SMDS group forgets its type after clearing, so we must re-set it
SMDSAbs_ElementType aSMDSType = aGroup->GetGroupDS()->GetType();
aGroup->GetGroupDS()->Clear();
aGroup->GetGroupDS()->SetType(aSMDSType);
return;
}
}
MESSAGE("attempt to clear a vague group");
}
//=============================================================================
/*!
*
*/
//=============================================================================
CORBA::Boolean SMESH_Group_i::Contains( CORBA::Long theID )
{
if ( myMeshServant ) {
::SMESH_Mesh& aMesh = myMeshServant->GetImpl();
::SMESH_Group* aGroup = aMesh.GetGroup(myLocalID);
if (aGroup) {
bool res = aGroup->GetGroupDS()->Contains(theID);
return res;
}
}
MESSAGE("attempt to check contents of a vague group");
return false;
}
//=============================================================================
/*!
*
*/
//=============================================================================
CORBA::Long SMESH_Group_i::Add( const SMESH::long_array& theIDs )
{
if ( myMeshServant ) {
::SMESH_Mesh& aMesh = myMeshServant->GetImpl();
::SMESH_Group* aGroup = aMesh.GetGroup(myLocalID);
if (aGroup) {
SMESHDS_Group* aGroupDS = aGroup->GetGroupDS();
int nbAdd = 0;
for (int i = 0; i < theIDs.length(); i++) {
int anID = (int) theIDs[i];
if (aGroupDS->Add(anID))
nbAdd++;
}
return nbAdd;
}
}
MESSAGE("attempt to add elements to a vague group");
return 0;
}
//=============================================================================
/*!
*
*/
//=============================================================================
CORBA::Long SMESH_Group_i::GetID( CORBA::Long theIndex )
{
if ( myMeshServant ) {
::SMESH_Mesh& aMesh = myMeshServant->GetImpl();
::SMESH_Group* aGroup = aMesh.GetGroup(myLocalID);
if (aGroup) {
int anID = aGroup->GetGroupDS()->GetID(theIndex);
return anID;
}
}
MESSAGE("attempt to iterate on a vague group");
return -1;
}
//=============================================================================
/*!
*
*/
//=============================================================================
SMESH::long_array* SMESH_Group_i::GetListOfID()
{
SMESH::long_array_var aRes = new SMESH::long_array();
if ( myMeshServant ) {
::SMESH_Mesh& aMesh = myMeshServant->GetImpl();
::SMESH_Group* aGroup = aMesh.GetGroup(myLocalID);
if (aGroup) {
SMESHDS_Group* aGroupDS = aGroup->GetGroupDS();
int aSize = aGroupDS->Extent();
aRes->length(aSize);
for (int i = 0; i < aSize; i++)
aRes[i] = aGroupDS->GetID(i+1);
return aRes._retn();
}
}
MESSAGE("get list of IDs of a vague group");
return aRes._retn();
}
//=============================================================================
/*!
*
*/
//=============================================================================
CORBA::Long SMESH_Group_i::Remove( const SMESH::long_array& theIDs )
{
if ( myMeshServant ) {
::SMESH_Mesh& aMesh = myMeshServant->GetImpl();
::SMESH_Group* aGroup = aMesh.GetGroup(myLocalID);
if (aGroup) {
// a SMDS group forgets its type after clearing, so we must re-set it
// if the group becomes empty
SMDSAbs_ElementType aSMDSType = aGroup->GetGroupDS()->GetType();
SMESHDS_Group* aGroupDS = aGroup->GetGroupDS();
int nbDel = 0;
for (int i = 0; i < theIDs.length(); i++) {
int anID = (int) theIDs[i];
if (aGroupDS->Remove(anID))
nbDel++;
}
if (aGroupDS->IsEmpty())
aGroupDS->SetType(aSMDSType);
return nbDel;
}
}
MESSAGE("attempt to remove elements from a vague group");
return 0;
}
//=============================================================================
/*!
*
*/
//=============================================================================
SMESH::SMESH_Mesh_ptr SMESH_Group_i::GetMesh()
{
MESSAGE("SMESH_Group_i::GetMesh(): mesh servant = " << myMeshServant );
SMESH::SMESH_Mesh_var aMesh;
if ( myMeshServant )
aMesh = SMESH::SMESH_Mesh::_narrow( myMeshServant->_this() );
return aMesh._retn();
}
//=============================================================================
/*!
*
*/
//=============================================================================
int SMESH_Group_i::GetLocalID()
{
return myLocalID;
}

View File

@ -0,0 +1,82 @@
// SMESH SMESH_I : idl implementation based on 'SMESH' unit's classes
//
// Copyright (C) 2004 CEA
//
// 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.
//
// 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.org
//
//
//
// File : SMESH_Group_i.hxx
// Author : Sergey ANIKIN, OCC
// Module : SMESH
// $Header$
#ifndef SMESH_Group_i_HeaderFile
#define SMESH_Group_i_HeaderFile
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_Group)
#include CORBA_SERVER_HEADER(SMESH_Mesh)
#include "SALOME_GenericObj_i.hh"
class SMESH_Mesh_i;
class SMESH_Group_i:
public virtual POA_SMESH::SMESH_Group,
public virtual SALOME::GenericObj_i
{
public:
SMESH_Group_i( PortableServer::POA_ptr thePOA, SMESH_Mesh_i* theMeshServant, const int theLocalID );
virtual ~SMESH_Group_i();
// CORBA interface implementation
void SetName( const char* theName );
char* GetName();
SMESH::ElementType GetType();
CORBA::Long Size();
CORBA::Boolean IsEmpty();
void Clear();
CORBA::Boolean Contains( CORBA::Long theID );
CORBA::Long Add( const SMESH::long_array& theIDs );
CORBA::Long GetID( CORBA::Long theIndex );
SMESH::long_array* GetListOfID();
CORBA::Long Remove( const SMESH::long_array& theIDs );
SMESH::SMESH_Mesh_ptr GetMesh();
// Internal C++ interface
int GetLocalID();
SMESH_Mesh_i* GetMeshServant() { return myMeshServant; }
private:
SMESH_Mesh_i* myMeshServant;
int myLocalID;
};
#endif

View File

@ -0,0 +1,227 @@
# Copyright (C) 2004 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
#
# 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.
#
# 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
#
#
#
# File : SMESH_control.py
# Author : Sergey LITONIN
# Module : SMESH
import SMESH
import SMESH_mechanic
smesh = SMESH_mechanic.smesh
mesh = SMESH_mechanic.mesh
salome = SMESH_mechanic.salome
aFilterMgr = smesh.CreateFilterManager()
# Criterion : AREA > 100
aFunctor = aFilterMgr.CreateArea()
aPredicate = aFilterMgr.CreateMoreThan()
aPredicate.SetNumFunctor( aFunctor )
aPredicate.SetMargin( 100 )
aFilter = aFilterMgr.CreateFilter()
aFilter.SetPredicate( aPredicate )
anIds = aFilter.GetElementsId( mesh )
# print result
print "Criterion: Area > 100 Nb = ", len( anIds )
#for i in range( len( anIds ) ):
#print anIds[ i ]
# create group
aGroup = mesh.CreateGroup( SMESH.FACE, "Area > 100" )
aGroup.Add( anIds )
# Criterion : Taper > 3e-15
aFunctor = aFilterMgr.CreateTaper()
aPredicate = aFilterMgr.CreateMoreThan()
aPredicate.SetNumFunctor( aFunctor )
aPredicate.SetMargin( 3e-15 )
aFilter = aFilterMgr.CreateFilter()
aFilter.SetPredicate( aPredicate )
anIds = aFilter.GetElementsId( mesh )
# print result
print "Criterion: Taper > 3e-15 Nb = ", len( anIds )
#for i in range( len( anIds ) ):
#print anIds[ i ]
# create group
aGroup = mesh.CreateGroup( SMESH.FACE, "Taper > 3e-15" )
aGroup.Add( anIds )
# Criterion : ASPECT RATIO > 1.3
aFunctor = aFilterMgr.CreateAspectRatio()
aPredicate = aFilterMgr.CreateMoreThan()
aPredicate.SetNumFunctor( aFunctor )
aPredicate.SetMargin( 1.3 )
aFilter = aFilterMgr.CreateFilter()
aFilter.SetPredicate( aPredicate )
anIds = aFilter.GetElementsId( mesh )
# print result
print "Criterion: Aspect Ratio > 1.3 Nb = ", len( anIds )
#for i in range( len( anIds ) ):
#print anIds[ i ]
# create group
aGroup = mesh.CreateGroup( SMESH.FACE, "Aspect Ratio > 1.3" )
aGroup.Add( anIds )
# Criterion : MINIMUM ANGLE < 30
aFunctor = aFilterMgr.CreateMinimumAngle()
aPredicate = aFilterMgr.CreateLessThan()
aPredicate.SetNumFunctor( aFunctor )
aPredicate.SetMargin( 30 )
aFilter = aFilterMgr.CreateFilter()
aFilter.SetPredicate( aPredicate )
anIds = aFilter.GetElementsId( mesh )
# print result
print "Criterion: Minimum Angle < 30 Nb = ", len( anIds )
#for i in range( len( anIds ) ):
#print anIds[ i ]
# create group
aGroup = mesh.CreateGroup( SMESH.FACE, "Minimum Angle < 30" )
aGroup.Add( anIds )
# Criterion : Warp > 2e-13
aFunctor = aFilterMgr.CreateWarping()
aPredicate = aFilterMgr.CreateMoreThan()
aPredicate.SetNumFunctor( aFunctor )
aPredicate.SetMargin( 2e-13 )
aFilter = aFilterMgr.CreateFilter()
aFilter.SetPredicate( aPredicate )
anIds = aFilter.GetElementsId( mesh )
# print result
print "Criterion: Warp > 2e-13 Nb = ", len( anIds )
#for i in range( len( anIds ) ):
#print anIds[ i ]
# create group
aGroup = mesh.CreateGroup( SMESH.FACE, "Warp > 2e-13" )
aGroup.Add( anIds )
# Criterion : Skew > 18
aFunctor = aFilterMgr.CreateSkew()
aPredicate = aFilterMgr.CreateMoreThan()
aPredicate.SetNumFunctor( aFunctor )
aPredicate.SetMargin( 18 )
aFilter = aFilterMgr.CreateFilter()
aFilter.SetPredicate( aPredicate )
anIds = aFilter.GetElementsId( mesh )
# print result
print "Criterion: Skew > 18 Nb = ", len( anIds )
#for i in range( len( anIds ) ):
#print anIds[ i ]
# create group
aGroup = mesh.CreateGroup( SMESH.FACE, "Skew > 18" )
aGroup.Add( anIds )
# Criterion : Length > 10
aFunctor = aFilterMgr.CreateLength()
aPredicate = aFilterMgr.CreateMoreThan()
aPredicate.SetNumFunctor( aFunctor )
aPredicate.SetMargin( 10 )
aFilter = aFilterMgr.CreateFilter()
aFilter.SetPredicate( aPredicate )
anIds = aFilter.GetElementsId( mesh )
# print result
print "Criterion: Length > 10 Nb = ", len( anIds )
#for i in range( len( anIds ) ):
#print anIds[ i ]
# create group
aGroup = mesh.CreateGroup( SMESH.EDGE, "Length > 10" )
aGroup.Add( anIds )
# Criterion : Borders at multi-connections = 2
aFunctor = aFilterMgr.CreateMultiConnection()
aPredicate = aFilterMgr.CreateEqualTo()
aPredicate.SetNumFunctor( aFunctor )
aPredicate.SetMargin( 2 )
aFilter = aFilterMgr.CreateFilter()
aFilter.SetPredicate( aPredicate )
anIds = aFilter.GetElementsId( mesh )
# print result
print "Criterion: Borders at multi-connections = 2 Nb = ", len( anIds )
#for i in range( len( anIds ) ):
#print anIds[ i ]
# create group
aGroup = mesh.CreateGroup( SMESH.EDGE, "Borders at multi-connections = 2" )
aGroup.Add( anIds )
salome.sg.updateObjBrowser(1)

View File

@ -0,0 +1,78 @@
import salome
from geompy import gg
import geompy
import SMESH
import StdMeshers
ShapeTypeCompSolid = 1
ShapeTypeSolid = 2
ShapeTypeShell = 3
ShapeTypeFace = 4
ShapeTypeWire = 5
ShapeTypeEdge = 6
ShapeTypeVertex = 7
geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM")
smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
geom.GetCurrentStudy(salome.myStudy._get_StudyId())
smesh.SetCurrentStudy(salome.myStudy)
# Create box without one plane
box = geompy.MakeBox(0., 0., 0., 10., 20., 30.)
subShapeList = geompy.SubShapeAll(box,ShapeTypeFace)
FaceList = []
for i in range( 5 ):
FaceList.append( subShapeList[ i ]._get_Name() )
aBox = geompy.MakeSewing( FaceList, 1. )
idbox = geompy.addToStudy( aBox, "box" )
aBox = salome.IDToObject( idbox )
# Create mesh
hyp1 = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
hyp1.SetNumberOfSegments(5)
hyp2 = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
hyp2.SetMaxElementArea(20)
hyp3 = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
hyp3.SetMaxElementArea(50)
algo1 = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
algo2 = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
mesh = smesh.CreateMesh(aBox)
mesh.AddHypothesis(aBox,hyp1)
mesh.AddHypothesis(aBox,hyp2)
mesh.AddHypothesis(aBox,algo1)
mesh.AddHypothesis(aBox,algo2)
smesh.Compute(mesh,aBox)
smeshgui = salome.ImportComponentGUI("SMESH")
smeshgui.Init(salome.myStudyId);
smeshgui.SetName( salome.ObjectToID( mesh ), "Mesh_freebord" );
# Criterion : Free edges
aFilterMgr = smesh.CreateFilterManager()
aPredicate = aFilterMgr.CreateFreeBorders()
aFilter = aFilterMgr.CreateFilter()
aFilter.SetPredicate( aPredicate )
anIds = aFilter.GetElementsId( mesh )
# print result
print "Criterion: Free edges Nb = ", len( anIds )
for i in range( len( anIds ) ):
print anIds[ i ]
# create group
aGroup = mesh.CreateGroup( SMESH.EDGE, "Free edges" )
aGroup.Add( anIds )
salome.sg.updateObjBrowser(1)

65
src/SMESH_SWIG/SMESH_test4.py Executable file
View File

@ -0,0 +1,65 @@
import salome
from geompy import gg
import geompy
import SMESH
import StdMeshers
ShapeTypeCompSolid = 1
ShapeTypeSolid = 2
ShapeTypeShell = 3
ShapeTypeFace = 4
ShapeTypeWire = 5
ShapeTypeEdge = 6
ShapeTypeVertex = 7
geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM")
smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
geom.GetCurrentStudy(salome.myStudy._get_StudyId())
smesh.SetCurrentStudy(salome.myStudy)
box = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
idbox = geompy.addToStudy(box,"box")
subShapeList = geompy.SubShapeAll(box,ShapeTypeFace)
face = subShapeList[0]
name = geompy.SubShapeName( face._get_Name(), box._get_Name() )
idface = geompy.addToStudyInFather(box,face,name)
box = salome.IDToObject(idbox)
face = salome.IDToObject(idface)
hyp1 = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
hyp1.SetNumberOfSegments(10)
hyp2 = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
hyp2.SetMaxElementArea(10)
hyp3 = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
hyp3.SetMaxElementArea(100)
algo1 = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
algo2 = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
mesh = smesh.CreateMesh(box)
mesh.AddHypothesis(box,hyp1)
mesh.AddHypothesis(box,hyp2)
mesh.AddHypothesis(box,algo1)
mesh.AddHypothesis(box,algo2)
submesh = mesh.GetSubMesh(face, "SubMeshFace")
mesh.AddHypothesis(face,hyp1)
mesh.AddHypothesis(face,hyp3)
mesh.AddHypothesis(face,algo1)
mesh.AddHypothesis(face,algo2)
smesh.Compute(mesh,box)
faces = submesh.GetElementsByType(SMESH.FACE)
if len(faces) > 1:
print len(faces), len(faces)/2
group1 = mesh.CreateGroup(SMESH.FACE,"Group of faces")
group2 = mesh.CreateGroup(SMESH.FACE,"Another group of faces")
group1.Add(faces[:int(len(faces)/2)])
group2.Add(faces[int(len(faces)/2):])
salome.sg.updateObjBrowser(1)

View File

@ -0,0 +1,79 @@
# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
#
# 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.
#
# 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
#
#
#
# File : SMESH_test1.py
# Module : SMESH
import salome
import SMESH
import SALOMEDS
import CORBA
import os
import os.path
def SetSObjName(theSObj,theName) :
ok, anAttr = theSObj.FindAttribute("AttributeName")
if ok:
aName = anAttr._narrow(SALOMEDS.AttributeName)
#print aName.__dict__
aName.SetValue(theName)
def ConvertMED2UNV(thePath,theFile) :
anInitFileName = thePath + theFile
aMeshes,aResult = smesh.CreateMeshesFromMED(anInitFileName)
print aResult, aMeshes
for iMesh in range(len(aMeshes)) :
aMesh = aMeshes[iMesh]
anSObj = salome.ObjectToSObject(aMesh)
print anSObj.GetName(),
aFileName = anInitFileName
aFileName = os.path.basename(aFileName)
SetSObjName(anSObj,aFileName)
print anSObj.GetName()
aFileName = thePath + theFile + "." + str(iMesh) + ".unv"
aMesh.ExportUNV(aFileName)
aMesh = smesh.CreateMeshesFromUNV(aFileName)
anSObj = salome.ObjectToSObject(aMesh)
print anSObj.GetName(),
os.remove(aFileName)
aFileName = os.path.basename(aFileName)
SetSObjName(anSObj,aFileName)
print anSObj.GetName()
smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
smesh.SetCurrentStudy(salome.myStudy)
aPath = os.getenv('KERNEL_ROOT_DIR') + '/examples/'
aListDir = os.listdir(aPath)
print aListDir
for iFile in range(len(aListDir)) :
aFileName = aListDir[iFile];
aName,anExt = os.path.splitext(aFileName)
if anExt == ".med" :
aFileName = os.path.basename(aFileName)
print aFileName
ConvertMED2UNV(aPath,aFileName)
#break
salome.sg.updateObjBrowser(1);

View File

@ -0,0 +1,150 @@
import os
import re
import batchmode_salome
import batchmode_geompy
import batchmode_smesh
geom = batchmode_geompy.geom
smesh = batchmode_smesh.smesh
geom.GetCurrentStudy(batchmode_salome.myStudyId)
smesh.SetCurrentStudy(batchmode_salome.myStudy)
ShapeType = batchmode_smesh.ShapeType
import StdMeshers
def CreateMesh (theFileName, area, len = None, nbseg = None):
if not(os.path.isfile(theFileName)) or re.search("\.brep$", theFileName) is None :
print "Incorrect file name !"
return
if (len is None) and (nbseg is None):
print "Define length or number of segments !"
return
if (len is not None) and (nbseg is not None):
print "Only one Hypothesis (from length and number of segments) can be defined !"
return
# ---- Import shape from BREP file and add it to the study
shape_mesh = geom.ImportBREP(theFileName)
Id_shape = batchmode_geompy.addToStudy( shape_mesh, "shape_mesh")
# ---- SMESH
# ---- create Hypothesis
print "-------------------------- create Hypothesis"
if (len is not None):
print "-------------------------- LocalLength"
hypLength1 = smesh.CreateHypothesis("LocalLength", "libStdMeshersEngine.so")
hypLength1.SetLength(len)
print "Hypothesis type: ", hypLength1.GetName()
print "Hypothesis ID: ", hypLength1.GetId()
print "Hypothesis Value: ", hypLength1.GetLength()
if (nbseg is not None):
print "-------------------------- NumberOfSegments"
hypNbSeg1 = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
hypNbSeg1.SetNumberOfSegments(nbseg)
print "Hypothesis type: ", hypNbSeg1.GetName()
print "Hypothesis ID: ", hypNbSeg1.GetId()
print "Hypothesis Value: ", hypNbSeg1.GetNumberOfSegments()
if (area == "LengthFromEdges"):
print "-------------------------- LengthFromEdges"
hypLengthFromEdges = smesh.CreateHypothesis("LengthFromEdges", "libStdMeshersEngine.so")
hypLengthFromEdges.SetMode(1)
print "Hypothesis type: ", hypLengthFromEdges.GetName()
print "Hypothesis ID: ", hypLengthFromEdges.GetId()
print "LengthFromEdges Mode: ", hypLengthFromEdges.GetMode()
else:
print "-------------------------- MaxElementArea"
hypArea1 = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
hypArea1.SetMaxElementArea(area)
print "Hypothesis type: ", hypArea1.GetName()
print "Hypothesis ID: ", hypArea1.GetId()
print "Hypothesis Value: ", hypArea1.GetMaxElementArea()
print "-------------------------- Regular_1D"
algoReg = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
listHyp = algoReg.GetCompatibleHypothesis()
for hyp in listHyp:
print hyp
print "Algo name: ", algoReg.GetName()
print "Algo ID: ", algoReg.GetId()
print "-------------------------- MEFISTO_2D"
algoMef = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
listHyp=algoMef.GetCompatibleHypothesis()
for hyp in listHyp:
print hyp
print "Algo name: ", algoMef.GetName()
print "Algo ID: ", algoMef.GetId()
# ---- add hypothesis to shape
print "-------------------------- add hypothesis to shape"
mesh = smesh.CreateMesh(shape_mesh)
ret = mesh.AddHypothesis(shape_mesh, algoReg)
print "Add Regular_1D algo .... ",
print ret
if (nbseg is not None):
ret=mesh.AddHypothesis(shape_mesh, hypNbSeg1)
print "Add Number Of Segements algo .... ",
print ret
if (len is not None):
ret=mesh.AddHypothesis(shape_mesh,hypLength1)
print "Add Local Length algo .... ",
print ret
ret=mesh.AddHypothesis(shape_mesh, algoMef)
print "Add MEFISTO_2D algo....",
print ret
if (area == "LengthFromEdges"):
ret = mesh.AddHypothesis( shape_mesh, hypLengthFromEdges) # length from edge
print "Add Length From Edges algo .... ",
print ret
else:
ret=mesh.AddHypothesis(shape_mesh, hypArea1)
print "Add Max Triangle Area algo .... ",
print ret
# ---- compute mesh
print "-------------------------- compute mesh"
ret=smesh.Compute(mesh,shape_mesh)
print "Compute Mesh .... ",
print ret
log=mesh.GetLog(0); # no erase trace
#for linelog in log:
# print linelog
print "------------ INFORMATION ABOUT MESH ------------"
print "Number of nodes: ", mesh.NbNodes()
print "Number of edges: ", mesh.NbEdges()
print "Number of faces: ", mesh.NbFaces()
print "Number of triangles: ", mesh.NbTriangles()
return mesh

View File

@ -0,0 +1,81 @@
# SMESH StdMeshers : implementaion of SMESH idl descriptions
#
# Copyright (C) 2003 CEA
#
# 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.
#
# 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.org
#
#
#
# File : Makefile.in
# Author : Julia DOROVSKIKH
# Module : SMESH
# $Header$
top_srcdir=@top_srcdir@
top_builddir=../..
srcdir=@srcdir@
VPATH=.:@srcdir@:@top_srcdir@/idl:$(top_builddir)/idl
@COMMENCE@
# header files
EXPORT_HEADERS = \
StdMeshers_LengthFromEdges.hxx \
StdMeshers_LocalLength.hxx \
StdMeshers_NumberOfSegments.hxx \
StdMeshers_MaxElementArea.hxx \
StdMeshers_MaxElementVolume.hxx \
StdMeshers_NotConformAllowed.hxx \
StdMeshers_Regular_1D.hxx \
StdMeshers_Quadrangle_2D.hxx \
StdMeshers_MEFISTO_2D.hxx \
StdMeshers_Hexa_3D.hxx
EXPORT_PYSCRIPTS =
# Libraries targets
LIB = libStdMeshers.la
LIB_SRC = \
StdMeshers_LengthFromEdges.cxx \
StdMeshers_LocalLength.cxx \
StdMeshers_MaxElementArea.cxx \
StdMeshers_MaxElementVolume.cxx \
StdMeshers_NumberOfSegments.cxx \
StdMeshers_NotConformAllowed.cxx \
StdMeshers_Regular_1D.cxx \
StdMeshers_Quadrangle_2D.cxx \
StdMeshers_MEFISTO_2D.cxx \
StdMeshers_Hexa_3D.cxx
LIB_SERVER_IDL =
LIB_CLIENT_IDL =
# Executables targets
BIN =
BIN_SRC =
# additionnal information to compil and link file
CPPFLAGS+= $(OCC_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome $(BOOST_CPPFLAGS)
CXXFLAGS+= $(OCC_CXXFLAGS) -I${KERNEL_ROOT_DIR}/include/salome
LDFLAGS+= -lSMESHimpl -lMEFISTO2D -L${KERNEL_ROOT_DIR}/lib/salome
@CONCLUDE@

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,140 @@
// SMESH SMESH : implementaion of SMESH idl descriptions
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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.
//
// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : StdMeshers_Hexa_3D.hxx
// Moved here from SMESH_Hexa_3D.hxx
// Author : Paul RASCLE, EDF
// Module : SMESH
// $Header$
#ifndef _SMESH_HEXA_3D_HXX_
#define _SMESH_HEXA_3D_HXX_
#include "SMESH_3D_Algo.hxx"
#include "SMESH_Mesh.hxx"
#include "StdMeshers_Quadrangle_2D.hxx"
#include "Utils_SALOME_Exception.hxx"
typedef struct point3Dstruct
{
const SMDS_MeshNode * node;
} Point3DStruct;
typedef double Pt3[3];
typedef struct conv2dstruct
{
double a1; // X = a1*x + b1*y + c1
double b1; // Y = a2*x + b2*y + c2
double c1; // a1, b1 a2, b2 in {-1,0,1}
double a2; // c1, c2 in {0,1}
double b2;
double c2;
int ia; // I = ia*i + ib*j + ic
int ib;
int ic;
int ja; // J = ja*i + jb*j + jc
int jb;
int jc;
} Conv2DStruct;
typedef struct cubeStruct
{
TopoDS_Vertex V000;
TopoDS_Vertex V001;
TopoDS_Vertex V010;
TopoDS_Vertex V011;
TopoDS_Vertex V100;
TopoDS_Vertex V101;
TopoDS_Vertex V110;
TopoDS_Vertex V111;
faceQuadStruct* quad_X0;
faceQuadStruct* quad_X1;
faceQuadStruct* quad_Y0;
faceQuadStruct* quad_Y1;
faceQuadStruct* quad_Z0;
faceQuadStruct* quad_Z1;
Point3DStruct* np; // normalised 3D coordinates
} CubeStruct;
class StdMeshers_Hexa_3D:
public SMESH_3D_Algo
{
public:
StdMeshers_Hexa_3D(int hypId, int studyId, SMESH_Gen* gen);
virtual ~StdMeshers_Hexa_3D();
virtual bool CheckHypothesis(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape,
SMESH_Hypothesis::Hypothesis_Status& aStatus);
virtual bool Compute(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape)
throw (SALOME_Exception);
ostream & SaveTo(ostream & save);
istream & LoadFrom(istream & load);
friend ostream & operator << (ostream & save, StdMeshers_Hexa_3D & hyp);
friend istream & operator >> (istream & load, StdMeshers_Hexa_3D & hyp);
protected:
TopoDS_Edge
EdgeNotInFace(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape,
const TopoDS_Face& aFace,
const TopoDS_Vertex& aVertex,
const TopTools_IndexedDataMapOfShapeListOfShape& MS);
int GetFaceIndex(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape,
const vector<SMESH_subMesh*>& meshFaces,
const TopoDS_Vertex& V0,
const TopoDS_Vertex& V1,
const TopoDS_Vertex& V2,
const TopoDS_Vertex& V3);
void GetConv2DCoefs(const faceQuadStruct& quad,
const TopoDS_Shape& aShape,
const TopoDS_Vertex& V0,
const TopoDS_Vertex& V1,
const TopoDS_Vertex& V2,
const TopoDS_Vertex& V3,
Conv2DStruct& conv);
void GetPoint(Pt3 p,
int i, int j, int k,
int nbx, int nby, int nbz,
Point3DStruct *np,
const SMESHDS_Mesh* meshDS);
CubeStruct _cube;
FaceQuadStruct* _quads[6];
int _indX0;
int _indX1;
int _indY0;
int _indY1;
int _indZ0;
int _indZ1;
};
#endif

View File

@ -0,0 +1,139 @@
// SMESH SMESH : implementaion of SMESH idl descriptions
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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.
//
// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : StdMeshers_LengthFromEdges.cxx
// Moved here from SMESH_LengthFromEdges.cxx
// Author : Paul RASCLE, EDF
// Module : SMESH
// $Header$
using namespace std;
#include "StdMeshers_LengthFromEdges.hxx"
#include "utilities.h"
//=============================================================================
/*!
*
*/
//=============================================================================
StdMeshers_LengthFromEdges::StdMeshers_LengthFromEdges(int hypId, int studyId, SMESH_Gen* gen)
: SMESH_Hypothesis(hypId, studyId, gen)
{
_mode =1;
_name = "LengthFromEdges";
// SCRUTE(_name);
// SCRUTE(&_name);
_param_algo_dim = 2; // is used by SMESH_MEFISTO_2D
}
//=============================================================================
/*!
*
*/
//=============================================================================
StdMeshers_LengthFromEdges::~StdMeshers_LengthFromEdges()
{
}
//=============================================================================
/*!
*
*/
//=============================================================================
void StdMeshers_LengthFromEdges::SetMode(int mode)
throw (SALOME_Exception)
{
int oldMode = _mode;
if (mode <= 0)
throw SALOME_Exception(LOCALIZED("mode must be positive"));
_mode = mode;
if (oldMode != _mode)
NotifySubMeshesHypothesisModification();
}
//=============================================================================
/*!
*
*/
//=============================================================================
int StdMeshers_LengthFromEdges::GetMode()
{
return _mode;
}
//=============================================================================
/*!
*
*/
//=============================================================================
ostream & StdMeshers_LengthFromEdges::SaveTo(ostream & save)
{
save << this->_mode;
return save;
}
//=============================================================================
/*!
*
*/
//=============================================================================
istream & StdMeshers_LengthFromEdges::LoadFrom(istream & load)
{
bool isOK = true;
int a;
isOK = (load >> a);
if (isOK)
this->_mode = a;
else
load.clear(ios::badbit | load.rdstate());
return load;
}
//=============================================================================
/*!
*
*/
//=============================================================================
ostream & operator << (ostream & save, StdMeshers_LengthFromEdges & hyp)
{
return hyp.SaveTo( save );
}
//=============================================================================
/*!
*
*/
//=============================================================================
istream & operator >> (istream & load, StdMeshers_LengthFromEdges & hyp)
{
return hyp.LoadFrom( load );
}

View File

@ -0,0 +1,57 @@
// SMESH SMESH : implementaion of SMESH idl descriptions
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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.
//
// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : StdMeshers_LengthFromEdges.hxx
// Moved here from SMESH_LengthFromEdges.hxx
// Author : Paul RASCLE, EDF
// Module : SMESH
// $Header$
#ifndef _SMESH_LENGTHFROMEDGES_HXX_
#define _SMESH_LENGTHFROMEDGES_HXX_
#include "SMESH_Hypothesis.hxx"
#include "Utils_SALOME_Exception.hxx"
class StdMeshers_LengthFromEdges:
public SMESH_Hypothesis
{
public:
StdMeshers_LengthFromEdges(int hypId, int studyId, SMESH_Gen* gen);
virtual ~StdMeshers_LengthFromEdges();
void SetMode(int mode)
throw (SALOME_Exception);
int GetMode();
virtual ostream & SaveTo(ostream & save);
virtual istream & LoadFrom(istream & load);
friend ostream & operator << (ostream & save, StdMeshers_LengthFromEdges & hyp);
friend istream & operator >> (istream & load, StdMeshers_LengthFromEdges & hyp);
protected:
int _mode;
};
#endif

View File

@ -0,0 +1,137 @@
// SMESH SMESH : implementaion of SMESH idl descriptions
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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.
//
// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : StdMeshers_LocalLength.cxx
// Moved here from SMESH_LocalLength.cxx
// Author : Paul RASCLE, EDF
// Module : SMESH
// $Header$
using namespace std;
#include "StdMeshers_LocalLength.hxx"
#include "utilities.h"
//=============================================================================
/*!
*
*/
//=============================================================================
StdMeshers_LocalLength::StdMeshers_LocalLength(int hypId, int studyId,
SMESH_Gen * gen):SMESH_Hypothesis(hypId, studyId, gen)
{
_length = 1.;
_name = "LocalLength";
// SCRUTE(_name);
// SCRUTE(&_name);
_param_algo_dim = 1; // is used by SMESH_Regular_1D
}
//=============================================================================
/*!
*
*/
//=============================================================================
StdMeshers_LocalLength::~StdMeshers_LocalLength()
{
}
//=============================================================================
/*!
*
*/
//=============================================================================
void StdMeshers_LocalLength::SetLength(double length) throw(SALOME_Exception)
{
double oldLength = _length;
if (length <= 0)
throw SALOME_Exception(LOCALIZED("length must be positive"));
_length = length;
if (oldLength != _length)
NotifySubMeshesHypothesisModification();
}
//=============================================================================
/*!
*
*/
//=============================================================================
double StdMeshers_LocalLength::GetLength() const
{
return _length;
}
//=============================================================================
/*!
*
*/
//=============================================================================
ostream & StdMeshers_LocalLength::SaveTo(ostream & save)
{
save << this->_length;
return save;
}
//=============================================================================
/*!
*
*/
//=============================================================================
istream & StdMeshers_LocalLength::LoadFrom(istream & load)
{
bool isOK = true;
double a;
isOK = (load >> a);
if (isOK)
this->_length = a;
else
load.clear(ios::badbit | load.rdstate());
return load;
}
//=============================================================================
/*!
*
*/
//=============================================================================
ostream & operator <<(ostream & save, StdMeshers_LocalLength & hyp)
{
return hyp.SaveTo( save );
}
//=============================================================================
/*!
*
*/
//=============================================================================
istream & operator >>(istream & load, StdMeshers_LocalLength & hyp)
{
return hyp.LoadFrom( load );
}

View File

@ -0,0 +1,55 @@
// SMESH SMESH : implementaion of SMESH idl descriptions
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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.
//
// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : StdMeshers_LocalLength.hxx
// Moved here from SMESH_LocalLength.hxx
// Author : Paul RASCLE, EDF
// Module : SMESH
// $Header$
#ifndef _SMESH_LOCALLENGTH_HXX_
#define _SMESH_LOCALLENGTH_HXX_
#include "SMESH_Hypothesis.hxx"
#include "Utils_SALOME_Exception.hxx"
class StdMeshers_LocalLength:public SMESH_Hypothesis
{
public:
StdMeshers_LocalLength(int hypId, int studyId, SMESH_Gen * gen);
virtual ~ StdMeshers_LocalLength();
void SetLength(double length) throw(SALOME_Exception);
double GetLength() const;
virtual ostream & SaveTo(ostream & save);
virtual istream & LoadFrom(istream & load);
friend ostream & operator <<(ostream & save, StdMeshers_LocalLength & hyp);
friend istream & operator >>(istream & load, StdMeshers_LocalLength & hyp);
protected:
double _length;
};
#endif

View File

@ -0,0 +1,643 @@
// SMESH SMESH : implementaion of SMESH idl descriptions
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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.
//
// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : StdMeshers_MEFISTO_2D.cxx
// Moved here from SMESH_MEFISTO_2D.cxx
// Author : Paul RASCLE, EDF
// Module : SMESH
// $Header$
using namespace std;
#include "StdMeshers_MEFISTO_2D.hxx"
#include "SMESH_Gen.hxx"
#include "SMESH_Mesh.hxx"
#include "StdMeshers_MaxElementArea.hxx"
#include "StdMeshers_LengthFromEdges.hxx"
#include "Rn.h"
#include "aptrte.h"
#include "SMDS_MeshElement.hxx"
#include "SMDS_MeshNode.hxx"
#include "SMDS_EdgePosition.hxx"
#include "SMDS_FacePosition.hxx"
#include "utilities.h"
#include <TopoDS_Face.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Shape.hxx>
#include <Geom_Surface.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <Geom2d_Curve.hxx>
#include <gp_Pnt2d.hxx>
#include <BRep_Tool.hxx>
#include <BRepTools.hxx>
#include <BRepTools_WireExplorer.hxx>
#include <GCPnts_AbscissaPoint.hxx>
#include <GCPnts_UniformAbscissa.hxx>
#include <TColStd_ListIteratorOfListOfInteger.hxx>
#include <string>
#include <algorithm>
//=============================================================================
/*!
*
*/
//=============================================================================
StdMeshers_MEFISTO_2D::StdMeshers_MEFISTO_2D(int hypId, int studyId,
SMESH_Gen * gen):SMESH_2D_Algo(hypId, studyId, gen)
{
MESSAGE("StdMeshers_MEFISTO_2D::StdMeshers_MEFISTO_2D");
_name = "MEFISTO_2D";
// _shapeType = TopAbs_FACE;
_shapeType = (1 << TopAbs_FACE);
_compatibleHypothesis.push_back("MaxElementArea");
_compatibleHypothesis.push_back("LengthFromEdges");
_edgeLength = 0;
_maxElementArea = 0;
_hypMaxElementArea = NULL;
_hypLengthFromEdges = NULL;
}
//=============================================================================
/*!
*
*/
//=============================================================================
StdMeshers_MEFISTO_2D::~StdMeshers_MEFISTO_2D()
{
MESSAGE("StdMeshers_MEFISTO_2D::~StdMeshers_MEFISTO_2D");
}
//=============================================================================
/*!
*
*/
//=============================================================================
bool StdMeshers_MEFISTO_2D::CheckHypothesis
(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape,
SMESH_Hypothesis::Hypothesis_Status& aStatus)
{
//MESSAGE("StdMeshers_MEFISTO_2D::CheckHypothesis");
_hypMaxElementArea = NULL;
_hypLengthFromEdges = NULL;
list <const SMESHDS_Hypothesis * >::const_iterator itl;
const SMESHDS_Hypothesis *theHyp;
const list <const SMESHDS_Hypothesis * >&hyps = GetUsedHypothesis(aMesh, aShape);
int nbHyp = hyps.size();
if (!nbHyp)
{
aStatus = SMESH_Hypothesis::HYP_MISSING;
return false; // can't work with no hypothesis
}
itl = hyps.begin();
theHyp = (*itl); // use only the first hypothesis
string hypName = theHyp->GetName();
int hypId = theHyp->GetID();
//SCRUTE(hypName);
bool isOk = false;
if (hypName == "MaxElementArea")
{
_hypMaxElementArea = static_cast<const StdMeshers_MaxElementArea *>(theHyp);
ASSERT(_hypMaxElementArea);
_maxElementArea = _hypMaxElementArea->GetMaxArea();
_edgeLength = 0;
isOk = true;
aStatus = SMESH_Hypothesis::HYP_OK;
}
else if (hypName == "LengthFromEdges")
{
_hypLengthFromEdges = static_cast<const StdMeshers_LengthFromEdges *>(theHyp);
ASSERT(_hypLengthFromEdges);
_edgeLength = 0;
_maxElementArea = 0;
isOk = true;
aStatus = SMESH_Hypothesis::HYP_OK;
}
else
aStatus = SMESH_Hypothesis::HYP_INCOMPATIBLE;
if (isOk)
{
isOk = false;
if (_maxElementArea > 0)
{
_edgeLength = 2 * sqrt(_maxElementArea); // triangles : minorant
isOk = true;
}
else
isOk = (_hypLengthFromEdges != NULL); // **** check mode
if (!isOk)
aStatus = SMESH_Hypothesis::HYP_BAD_PARAMETER;
}
//SCRUTE(_edgeLength);
//SCRUTE(_maxElementArea);
return isOk;
}
//=============================================================================
/*!
*
*/
//=============================================================================
bool StdMeshers_MEFISTO_2D::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
{
MESSAGE("StdMeshers_MEFISTO_2D::Compute");
if (_hypLengthFromEdges)
_edgeLength = ComputeEdgeElementLength(aMesh, aShape);
bool isOk = false;
const SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
SMESH_subMesh *theSubMesh = aMesh.GetSubMesh(aShape);
const TopoDS_Face & FF = TopoDS::Face(aShape);
bool faceIsForward = (FF.Orientation() == TopAbs_FORWARD);
TopoDS_Face F = TopoDS::Face(FF.Oriented(TopAbs_FORWARD));
Z nblf; //nombre de lignes fermees (enveloppe en tete)
Z *nudslf = NULL; //numero du dernier sommet de chaque ligne fermee
R2 *uvslf = NULL;
Z nbpti = 0; //nombre points internes futurs sommets de la triangulation
R2 *uvpti = NULL;
Z nbst;
R2 *uvst = NULL;
Z nbt;
Z *nust = NULL;
Z ierr = 0;
Z nutysu = 1; // 1: il existe un fonction areteideale_()
// Z nutysu=0; // 0: on utilise aretmx
R aretmx = _edgeLength; // longueur max aretes future triangulation
//SCRUTE(aretmx);
nblf = NumberOfWires(F);
//SCRUTE(nblf);
nudslf = new Z[1 + nblf];
nudslf[0] = 0;
int iw = 1;
int nbpnt = 0;
const TopoDS_Wire OW1 = BRepTools::OuterWire(F);
nbpnt += NumberOfPoints(aMesh, OW1);
nudslf[iw++] = nbpnt;
//SCRUTE(nbpnt);
for (TopExp_Explorer exp(F, TopAbs_WIRE); exp.More(); exp.Next())
{
const TopoDS_Wire & W = TopoDS::Wire(exp.Current());
if (!OW1.IsSame(W))
{
nbpnt += NumberOfPoints(aMesh, W);
nudslf[iw++] = nbpnt;
//SCRUTE(nbpnt);
}
}
uvslf = new R2[nudslf[nblf]];
//SCRUTE(nudslf[nblf]);
int m = 0;
map<int, const SMDS_MeshNode*> mefistoToDS; // correspondence mefisto index--> points IDNodes
TopoDS_Wire OW = BRepTools::OuterWire(F);
LoadPoints(aMesh, F, OW, uvslf, m, mefistoToDS);
//SCRUTE(m);
for (TopExp_Explorer exp(F, TopAbs_WIRE); exp.More(); exp.Next())
{
const TopoDS_Wire & W = TopoDS::Wire(exp.Current());
if (!OW.IsSame(W))
{
LoadPoints(aMesh, F, W, uvslf, m, mefistoToDS);
//SCRUTE(m);
}
}
// SCRUTE(nudslf[nblf]);
// for (int i=0; i<=nblf; i++)
// {
// MESSAGE(" -+- " <<i<< " "<< nudslf[i]);
// }
// for (int i=0; i<nudslf[nblf]; i++)
// {
// MESSAGE(" -+- " <<i<< " "<< uvslf[i]);
// }
// SCRUTE(nutysu);
// SCRUTE(aretmx);
// SCRUTE(nblf);
MESSAGE("MEFISTO triangulation ...");
uvst = NULL;
nust = NULL;
aptrte(nutysu, aretmx,
nblf, nudslf, uvslf, nbpti, uvpti, nbst, uvst, nbt, nust, ierr);
if (ierr == 0)
{
MESSAGE("... End Triangulation Generated Triangle Number " << nbt);
MESSAGE(" Node Number " << nbst);
//SCRUTE(nbst);
//SCRUTE(nbt);
StoreResult(aMesh, nbst, uvst, nbt, nust, F,
faceIsForward, mefistoToDS);
isOk = true;
}
else
{
MESSAGE("Error in Triangulation");
isOk = false;
}
if (nudslf != NULL)
delete[]nudslf;
if (uvslf != NULL)
delete[]uvslf;
if (uvst != NULL)
delete[]uvst;
if (nust != NULL)
delete[]nust;
return isOk;
}
//=============================================================================
/*!
*
*/
//=============================================================================
void StdMeshers_MEFISTO_2D::LoadPoints(SMESH_Mesh & aMesh,
const TopoDS_Face & FF,
const TopoDS_Wire & WW, R2 * uvslf, int &m,
map<int, const SMDS_MeshNode*>&mefistoToDS)
{
MESSAGE("StdMeshers_MEFISTO_2D::LoadPoints");
SMDS_Mesh * meshDS = aMesh.GetMeshDS();
double scalex;
double scaley;
TopoDS_Face F = TopoDS::Face(FF.Oriented(TopAbs_FORWARD));
ComputeScaleOnFace(aMesh, F, scalex, scaley);
TopoDS_Wire W = TopoDS::Wire(WW.Oriented(TopAbs_FORWARD));
BRepTools_WireExplorer wexp(W, F);
for (wexp.Init(W, F); wexp.More(); wexp.Next())
{
const TopoDS_Edge & E = wexp.Current();
// --- IDNodes of first and last Vertex
TopoDS_Vertex VFirst, VLast;
TopExp::Vertices(E, VFirst, VLast); // corresponds to f and l
ASSERT(!VFirst.IsNull());
SMDS_NodeIteratorPtr lid=
aMesh.GetSubMesh(VFirst)->GetSubMeshDS()->GetNodes();
const SMDS_MeshNode* idFirst = lid->next();
ASSERT(!VLast.IsNull());
lid=aMesh.GetSubMesh(VLast)->GetSubMeshDS()->GetNodes();
const SMDS_MeshNode* idLast = lid->next();
// --- edge internal IDNodes (relies on good order storage, not checked)
int nbPoints = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
//SCRUTE(nbPoints);
double f, l;
Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E, F, f, l);
SMDS_NodeIteratorPtr ite= aMesh.GetSubMesh(E)->GetSubMeshDS()->GetNodes();
bool isForward = (E.Orientation() == TopAbs_FORWARD);
map<double, const SMDS_MeshNode*> params;
while(ite->more())
{
const SMDS_MeshNode * node = ite->next();
const SMDS_EdgePosition* epos =
static_cast<const SMDS_EdgePosition*>(node->GetPosition().get());
double param = epos->GetUParameter();
params[param] = node;
}
// --- load 2D values into MEFISTO structure,
// add IDNodes in mefistoToDS map
if (E.Orientation() == TopAbs_FORWARD)
{
gp_Pnt2d p = C2d->Value(f); // first point = Vertex Forward
uvslf[m].x = scalex * p.X();
uvslf[m].y = scaley * p.Y();
mefistoToDS[m + 1] = idFirst;
//MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]);
//MESSAGE("__ f "<<f<<" "<<uvslf[m].x <<" "<<uvslf[m].y);
m++;
map<double, const SMDS_MeshNode*>::iterator itp = params.begin();
for (int i = 1; i <= nbPoints; i++) // nbPoints internal
{
double param = (*itp).first;
gp_Pnt2d p = C2d->Value(param);
uvslf[m].x = scalex * p.X();
uvslf[m].y = scaley * p.Y();
mefistoToDS[m + 1] = (*itp).second;
// MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]);
// MESSAGE("__ "<<i<<" "<<param<<" "<<uvslf[m].x <<" "<<uvslf[m].y);
m++;
itp++;
}
}
else
{
gp_Pnt2d p = C2d->Value(l); // last point = Vertex Reversed
uvslf[m].x = scalex * p.X();
uvslf[m].y = scaley * p.Y();
mefistoToDS[m + 1] = idLast;
// MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]);
// MESSAGE("__ l "<<l<<" "<<uvslf[m].x <<" "<<uvslf[m].y);
m++;
map<double, const SMDS_MeshNode*>::reverse_iterator itp = params.rbegin();
for (int i = nbPoints; i >= 1; i--)
{
double param = (*itp).first;
gp_Pnt2d p = C2d->Value(param);
uvslf[m].x = scalex * p.X();
uvslf[m].y = scaley * p.Y();
mefistoToDS[m + 1] = (*itp).second;
// MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]);
// MESSAGE("__ "<<i<<" "<<param<<" "<<uvslf[m].x <<" "<<uvslf[m].y);
m++;
itp++;
}
}
}
}
//=============================================================================
/*!
*
*/
//=============================================================================
// **** a mettre dans SMESH_Algo ou SMESH_2D_Algo
void StdMeshers_MEFISTO_2D::ComputeScaleOnFace(SMESH_Mesh & aMesh,
const TopoDS_Face & aFace, double &scalex, double &scaley)
{
//MESSAGE("StdMeshers_MEFISTO_2D::ComputeScaleOnFace");
TopoDS_Face F = TopoDS::Face(aFace.Oriented(TopAbs_FORWARD));
TopoDS_Wire W = BRepTools::OuterWire(F);
BRepTools_WireExplorer wexp(W, F);
double xmin = 1.e300; // min & max of face 2D parametric coord.
double xmax = -1.e300;
double ymin = 1.e300;
double ymax = -1.e300;
int nbp = 50;
scalex = 1;
scaley = 1;
for (wexp.Init(W, F); wexp.More(); wexp.Next())
{
const TopoDS_Edge & E = wexp.Current();
double f, l;
Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E, F, f, l);
for (int i = 0; i <= nbp; i++)
{
double param = f + (double (i) / double (nbp))*(l - f);
gp_Pnt2d p = C2d->Value(param);
if (p.X() < xmin)
xmin = p.X();
if (p.X() > xmax)
xmax = p.X();
if (p.Y() < ymin)
ymin = p.Y();
if (p.Y() > ymax)
ymax = p.Y();
// MESSAGE(" "<< f<<" "<<l<<" "<<param<<" "<<xmin<<" "<<xmax<<" "<<ymin<<" "<<ymax);
}
}
// SCRUTE(xmin);
// SCRUTE(xmax);
// SCRUTE(ymin);
// SCRUTE(ymax);
double xmoy = (xmax + xmin) / 2.;
double ymoy = (ymax + ymin) / 2.;
Handle(Geom_Surface) S = BRep_Tool::Surface(F); // 3D surface
double length_x = 0;
double length_y = 0;
gp_Pnt PX0 = S->Value(xmin, ymoy);
gp_Pnt PY0 = S->Value(xmoy, ymin);
for (int i = 1; i <= nbp; i++)
{
double x = xmin + (double (i) / double (nbp))*(xmax - xmin);
gp_Pnt PX = S->Value(x, ymoy);
double y = ymin + (double (i) / double (nbp))*(ymax - ymin);
gp_Pnt PY = S->Value(xmoy, y);
length_x += PX.Distance(PX0);
length_y += PY.Distance(PY0);
PX0.SetCoord(PX.X(), PX.Y(), PX.Z());
PY0.SetCoord(PY.X(), PY.Y(), PY.Z());
}
// SCRUTE(length_x);
// SCRUTE(length_y);
scalex = length_x / (xmax - xmin);
scaley = length_y / (ymax - ymin);
// SCRUTE(scalex);
// SCRUTE(scaley);
ASSERT(scalex);
ASSERT(scaley);
}
//=============================================================================
/*!
*
*/
//=============================================================================
void StdMeshers_MEFISTO_2D::StoreResult(SMESH_Mesh & aMesh,
Z nbst, R2 * uvst, Z nbt, Z * nust,
const TopoDS_Face & F, bool faceIsForward,
map<int, const SMDS_MeshNode*>&mefistoToDS)
{
double scalex;
double scaley;
ComputeScaleOnFace(aMesh, F, scalex, scaley);
SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
Z n, m;
Handle(Geom_Surface) S = BRep_Tool::Surface(F);
for (n = 0; n < nbst; n++)
{
double u = uvst[n][0] / scalex;
double v = uvst[n][1] / scaley;
gp_Pnt P = S->Value(u, v);
if (mefistoToDS.find(n + 1) == mefistoToDS.end())
{
SMDS_MeshNode * node = meshDS->AddNode(P.X(), P.Y(), P.Z());
meshDS->SetNodeOnFace(node, F);
//MESSAGE(nodeId<<" "<<P.X()<<" "<<P.Y()<<" "<<P.Z());
mefistoToDS[n + 1] = node;
//MESSAGE(" "<<n<<" "<<mefistoToDS[n+1]);
SMDS_FacePosition* fpos =
static_cast<SMDS_FacePosition*>(node->GetPosition().get());
fpos->SetUParameter(u);
fpos->SetVParameter(v);
}
}
m = 0;
int mt = 0;
//SCRUTE(faceIsForward);
for (n = 1; n <= nbt; n++)
{
int inode1 = nust[m++];
int inode2 = nust[m++];
int inode3 = nust[m++];
const SMDS_MeshNode *n1, *n2, *n3;
n1 = mefistoToDS[inode1];
n2 = mefistoToDS[inode2];
n3 = mefistoToDS[inode3];
//MESSAGE("-- "<<inode1<<" "<<inode2<<" "<<inode3<<" ++ "<<nodeId1<<" "<<nodeId2<<" "<<nodeId3);
// triangle points must be in trigonometric order if face is Forward
// else they must be put clockwise
bool triangleIsWellOriented = faceIsForward;
SMDS_MeshElement * elt;
if (triangleIsWellOriented)
elt = meshDS->AddFace(n1, n2, n3);
else
elt = meshDS->AddFace(n1, n3, n2);
meshDS->SetMeshElementOnShape(elt, F);
m++;
}
}
//=============================================================================
/*!
*
*/
//=============================================================================
double StdMeshers_MEFISTO_2D::ComputeEdgeElementLength(SMESH_Mesh & aMesh,
const TopoDS_Shape & aShape)
{
MESSAGE("StdMeshers_MEFISTO_2D::ComputeEdgeElementLength");
// **** a mettre dans SMESH_2D_Algo ?
const TopoDS_Face & FF = TopoDS::Face(aShape);
bool faceIsForward = (FF.Orientation() == TopAbs_FORWARD);
TopoDS_Face F = TopoDS::Face(FF.Oriented(TopAbs_FORWARD));
double meanElementLength = 100;
double wireLength = 0;
int wireElementsNumber = 0;
for (TopExp_Explorer exp(F, TopAbs_WIRE); exp.More(); exp.Next())
{
const TopoDS_Wire & W = TopoDS::Wire(exp.Current());
for (TopExp_Explorer expe(W, TopAbs_EDGE); expe.More(); expe.Next())
{
const TopoDS_Edge & E = TopoDS::Edge(expe.Current());
int nb = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
double length = EdgeLength(E);
wireLength += length;
wireElementsNumber += nb;
}
}
if (wireElementsNumber)
meanElementLength = wireLength / wireElementsNumber;
//SCRUTE(meanElementLength);
return meanElementLength;
}
//=============================================================================
/*!
*
*/
//=============================================================================
ostream & StdMeshers_MEFISTO_2D::SaveTo(ostream & save)
{
return save;
}
//=============================================================================
/*!
*
*/
//=============================================================================
istream & StdMeshers_MEFISTO_2D::LoadFrom(istream & load)
{
return load;
}
//=============================================================================
/*!
*
*/
//=============================================================================
ostream & operator <<(ostream & save, StdMeshers_MEFISTO_2D & hyp)
{
return hyp.SaveTo( save );
}
//=============================================================================
/*!
*
*/
//=============================================================================
istream & operator >>(istream & load, StdMeshers_MEFISTO_2D & hyp)
{
return hyp.LoadFrom( load );
}

View File

@ -0,0 +1,88 @@
// SMESH SMESH : implementaion of SMESH idl descriptions
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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.
//
// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : StdMeshers_MEFISTO_2D.hxx
// Moved here from SMESH_MEFISTO_2D.hxx
// Author : Paul RASCLE, EDF
// Module : SMESH
// $Header$
#ifndef _StdMeshers_MEFISTO_2D_HXX_
#define _StdMeshers_MEFISTO_2D_HXX_
#include "SMESH_2D_Algo.hxx"
#include "StdMeshers_MaxElementArea.hxx"
#include "StdMeshers_LengthFromEdges.hxx"
#include "Rn.h"
class SMDS_MeshNode;
#include <TopoDS_Face.hxx>
#include <map>
class StdMeshers_MEFISTO_2D:
public SMESH_2D_Algo
{
public:
StdMeshers_MEFISTO_2D(int hypId, int studyId, SMESH_Gen* gen);
virtual ~StdMeshers_MEFISTO_2D();
virtual bool CheckHypothesis(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape,
SMESH_Hypothesis::Hypothesis_Status& aStatus);
virtual bool Compute(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape);
double ComputeEdgeElementLength(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape);
void LoadPoints(SMESH_Mesh& aMesh,
const TopoDS_Face& F,
const TopoDS_Wire& W,
R2* uvslf,
int& m,
map<int,const SMDS_MeshNode*>& mefistoToDS);
void ComputeScaleOnFace(SMESH_Mesh& aMesh,
const TopoDS_Face& aFace,
double& scalex,
double& scaley);
void StoreResult (SMESH_Mesh& aMesh,
Z nbst, R2* uvst, Z nbt, Z* nust,
const TopoDS_Face& F, bool faceIsForward,
map<int,const SMDS_MeshNode*>& mefistoToDS);
ostream & SaveTo(ostream & save);
istream & LoadFrom(istream & load);
friend ostream & operator << (ostream & save, StdMeshers_MEFISTO_2D & hyp);
friend istream & operator >> (istream & load, StdMeshers_MEFISTO_2D & hyp);
protected:
double _edgeLength;
double _maxElementArea;
const StdMeshers_MaxElementArea* _hypMaxElementArea;
const StdMeshers_LengthFromEdges* _hypLengthFromEdges;
};
#endif

View File

@ -0,0 +1,139 @@
// SMESH SMESH : implementaion of SMESH idl descriptions
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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.
//
// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : StdMeshers_MaxElementArea.cxx
// Moved here from SMESH_MaxElementArea.cxx
// Author : Paul RASCLE, EDF
// Module : SMESH
// $Header$
using namespace std;
#include "StdMeshers_MaxElementArea.hxx"
#include "utilities.h"
//=============================================================================
/*!
*
*/
//=============================================================================
StdMeshers_MaxElementArea::StdMeshers_MaxElementArea(int hypId, int studyId, SMESH_Gen* gen)
: SMESH_Hypothesis(hypId, studyId, gen)
{
_maxArea =1.;
_name = "MaxElementArea";
// SCRUTE(_name);
// SCRUTE(&_name);
_param_algo_dim = 2;
}
//=============================================================================
/*!
*
*/
//=============================================================================
StdMeshers_MaxElementArea::~StdMeshers_MaxElementArea()
{
}
//=============================================================================
/*!
*
*/
//=============================================================================
void StdMeshers_MaxElementArea::SetMaxArea(double maxArea)
throw (SALOME_Exception)
{
double oldArea = _maxArea;
if (maxArea <= 0)
throw SALOME_Exception(LOCALIZED("maxArea must be positive"));
_maxArea = maxArea;
if (_maxArea != oldArea)
NotifySubMeshesHypothesisModification();
}
//=============================================================================
/*!
*
*/
//=============================================================================
double StdMeshers_MaxElementArea::GetMaxArea() const
{
return _maxArea;
}
//=============================================================================
/*!
*
*/
//=============================================================================
ostream & StdMeshers_MaxElementArea::SaveTo(ostream & save)
{
save << this->_maxArea;
return save;
}
//=============================================================================
/*!
*
*/
//=============================================================================
istream & StdMeshers_MaxElementArea::LoadFrom(istream & load)
{
bool isOK = true;
double a;
isOK = (load >> a);
if (isOK)
this->_maxArea = a;
else
load.clear(ios::badbit | load.rdstate());
return load;
}
//=============================================================================
/*!
*
*/
//=============================================================================
ostream & operator << (ostream & save, StdMeshers_MaxElementArea & hyp)
{
return hyp.SaveTo( save );
}
//=============================================================================
/*!
*
*/
//=============================================================================
istream & operator >> (istream & load, StdMeshers_MaxElementArea & hyp)
{
return hyp.LoadFrom( load );
}

View File

@ -0,0 +1,55 @@
// SMESH SMESH : implementaion of SMESH idl descriptions
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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.
//
// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : StdMeshers_MaxElementArea.hxx
// Moved here from SMESH_MaxElementArea.hxx
// Author : Paul RASCLE, EDF
// Module : SMESH
// $Header$
#ifndef _SMESH_MAXELEMENTAREA_HXX_
#define _SMESH_MAXELEMENTAREA_HXX_
#include "SMESH_Hypothesis.hxx"
#include "Utils_SALOME_Exception.hxx"
class StdMeshers_MaxElementArea:public SMESH_Hypothesis
{
public:
StdMeshers_MaxElementArea(int hypId, int studyId, SMESH_Gen * gen);
virtual ~ StdMeshers_MaxElementArea();
void SetMaxArea(double maxArea) throw(SALOME_Exception);
double GetMaxArea() const;
virtual ostream & SaveTo(ostream & save);
virtual istream & LoadFrom(istream & load);
friend ostream & operator <<(ostream & save, StdMeshers_MaxElementArea & hyp);
friend istream & operator >>(istream & load, StdMeshers_MaxElementArea & hyp);
protected:
double _maxArea;
};
#endif

View File

@ -0,0 +1,141 @@
// SMESH SMESH : implementaion of SMESH idl descriptions
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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.
//
// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : StdMeshers_MaxElementVolume.cxx
// Moved here from SMESH_MaxElementVolume.cxx
// Author : Paul RASCLE, EDF
// Module : SMESH
// $Header$
using namespace std;
#include "StdMeshers_MaxElementVolume.hxx"
#include "utilities.h"
//=============================================================================
/*!
*
*/
//=============================================================================
StdMeshers_MaxElementVolume::StdMeshers_MaxElementVolume(int hypId, int studyId, SMESH_Gen* gen)
: SMESH_Hypothesis(hypId, studyId, gen)
{
_maxVolume =1.;
_name = "MaxElementVolume";
// SCRUTE(_name);
SCRUTE(&_name);
_param_algo_dim = 3;
}
//=============================================================================
/*!
*
*/
//=============================================================================
StdMeshers_MaxElementVolume::~StdMeshers_MaxElementVolume()
{
MESSAGE("StdMeshers_MaxElementVolume::~StdMeshers_MaxElementVolume");
}
//=============================================================================
/*!
*
*/
//=============================================================================
void StdMeshers_MaxElementVolume::SetMaxVolume(double maxVolume)
throw (SALOME_Exception)
{
double oldVolume = _maxVolume;
if (maxVolume <= 0)
throw SALOME_Exception(LOCALIZED("maxVolume must be positive"));
_maxVolume = maxVolume;
if (_maxVolume != oldVolume)
NotifySubMeshesHypothesisModification();
}
//=============================================================================
/*!
*
*/
//=============================================================================
double StdMeshers_MaxElementVolume::GetMaxVolume() const
{
return _maxVolume;
}
//=============================================================================
/*!
*
*/
//=============================================================================
ostream & StdMeshers_MaxElementVolume::SaveTo(ostream & save)
{
save << this->_maxVolume;
return save;
}
//=============================================================================
/*!
*
*/
//=============================================================================
istream & StdMeshers_MaxElementVolume::LoadFrom(istream & load)
{
bool isOK = true;
double a;
isOK = (load >> a);
if (isOK)
this->_maxVolume = a;
else
load.clear(ios::badbit | load.rdstate());
return load;
}
//=============================================================================
/*!
*
*/
//=============================================================================
ostream & operator << (ostream & save, StdMeshers_MaxElementVolume & hyp)
{
return hyp.SaveTo( save );
}
//=============================================================================
/*!
*
*/
//=============================================================================
istream & operator >> (istream & load, StdMeshers_MaxElementVolume & hyp)
{
return hyp.LoadFrom( load );
}

View File

@ -0,0 +1,57 @@
// SMESH SMESH : implementaion of SMESH idl descriptions
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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.
//
// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : StdMeshers_MaxElementVolume.hxx
// Moved here from SMESH_MaxElementVolume.hxx
// Author : Paul RASCLE, EDF
// Module : SMESH
// $Header$
#ifndef _SMESH_MAXELEMENTVOLUME_HXX_
#define _SMESH_MAXELEMENTVOLUME_HXX_
#include "SMESH_Hypothesis.hxx"
#include "Utils_SALOME_Exception.hxx"
class StdMeshers_MaxElementVolume:
public SMESH_Hypothesis
{
public:
StdMeshers_MaxElementVolume(int hypId, int studyId, SMESH_Gen* gen);
virtual ~StdMeshers_MaxElementVolume();
void SetMaxVolume(double maxVolume)
throw (SALOME_Exception);
double GetMaxVolume() const;
virtual ostream & SaveTo(ostream & save);
virtual istream & LoadFrom(istream & load);
friend ostream & operator << (ostream & save, StdMeshers_MaxElementVolume & hyp);
friend istream & operator >> (istream & load, StdMeshers_MaxElementVolume & hyp);
protected:
double _maxVolume;
};
#endif

View File

@ -0,0 +1,98 @@
// SMESH StdMeshers : implementaion of SMESH idl descriptions
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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.
//
// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : StdMeshers_NotConformAllowed.cxx
// Author : Paul RASCLE, EDF
// Module : SMESH
// $Header$
using namespace std;
#include "StdMeshers_NotConformAllowed.hxx"
#include "utilities.h"
//=============================================================================
/*!
*
*/
//=============================================================================
StdMeshers_NotConformAllowed::StdMeshers_NotConformAllowed(int hypId, int studyId, SMESH_Gen* gen)
: SMESH_Hypothesis(hypId, studyId, gen)
{
_name = "NotConformAllowed";
_param_algo_dim = -1;
}
//=============================================================================
/*!
*
*/
//=============================================================================
StdMeshers_NotConformAllowed::~StdMeshers_NotConformAllowed()
{
}
//=============================================================================
/*!
*
*/
//=============================================================================
ostream & StdMeshers_NotConformAllowed::SaveTo(ostream & save)
{
return save << this;
}
//=============================================================================
/*!
*
*/
//=============================================================================
istream & StdMeshers_NotConformAllowed::LoadFrom(istream & load)
{
return load >> (*this);
}
//=============================================================================
/*!
*
*/
//=============================================================================
ostream & operator << (ostream & save, StdMeshers_NotConformAllowed & hyp)
{
return save;
}
//=============================================================================
/*!
*
*/
//=============================================================================
istream & operator >> (istream & load, StdMeshers_NotConformAllowed & hyp)
{
return load;
}

View File

@ -0,0 +1,48 @@
// SMESH StdMeshers : implementaion of SMESH idl descriptions
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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.
//
// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : StdMeshers_NotConformAllowed.hxx
// Author : Paul RASCLE, EDF
// Module : SMESH
// $Header$
#ifndef _StdMeshers_NotConformAllowed_HXX_
#define _StdMeshers_NotConformAllowed_HXX_
#include "SMESH_Hypothesis.hxx"
#include "Utils_SALOME_Exception.hxx"
class StdMeshers_NotConformAllowed:
public SMESH_Hypothesis
{
public:
StdMeshers_NotConformAllowed(int hypId, int studyId, SMESH_Gen* gen);
virtual ~StdMeshers_NotConformAllowed();
virtual ostream & SaveTo(ostream & save);
virtual istream & LoadFrom(istream & load);
friend ostream & operator << (ostream & save, StdMeshers_NotConformAllowed & hyp);
friend istream & operator >> (istream & load, StdMeshers_NotConformAllowed & hyp);
};
#endif

View File

@ -0,0 +1,171 @@
// SMESH SMESH : implementaion of SMESH idl descriptions
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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.
//
// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : StdMeshers_NumberOfSegments.cxx
// Moved here from SMESH_NumberOfSegments.cxx
// Author : Paul RASCLE, EDF
// Module : SMESH
// $Header$
using namespace std;
#include "StdMeshers_NumberOfSegments.hxx"
//=============================================================================
/*!
*
*/
//=============================================================================
StdMeshers_NumberOfSegments::StdMeshers_NumberOfSegments(int hypId, int studyId,
SMESH_Gen * gen):SMESH_Hypothesis(hypId, studyId, gen)
{
_numberOfSegments = 1;
_scaleFactor = 1.0;
_name = "NumberOfSegments";
_param_algo_dim = 1;
}
//=============================================================================
/*!
*
*/
//=============================================================================
StdMeshers_NumberOfSegments::~StdMeshers_NumberOfSegments()
{
}
//=============================================================================
/*!
*
*/
//=============================================================================
void StdMeshers_NumberOfSegments::SetNumberOfSegments(int segmentsNumber)
throw(SALOME_Exception)
{
int oldNumberOfSegments = _numberOfSegments;
if (segmentsNumber <= 0)
throw
SALOME_Exception(LOCALIZED("number of segments must be positive"));
_numberOfSegments = segmentsNumber;
if (oldNumberOfSegments != _numberOfSegments)
NotifySubMeshesHypothesisModification();
}
//=============================================================================
/*!
*
*/
//=============================================================================
int StdMeshers_NumberOfSegments::GetNumberOfSegments() const
{
return _numberOfSegments;
}
//=============================================================================
/*!
*
*/
//=============================================================================
void StdMeshers_NumberOfSegments::SetScaleFactor(double scaleFactor)
throw(SALOME_Exception)
{
if (scaleFactor < 0)
throw SALOME_Exception(LOCALIZED("scale factor must be positive"));
_scaleFactor = scaleFactor;
NotifySubMeshesHypothesisModification();
}
//=============================================================================
/*!
*
*/
//=============================================================================
double StdMeshers_NumberOfSegments::GetScaleFactor() const
{
return _scaleFactor;
}
//=============================================================================
/*!
*
*/
//=============================================================================
ostream & StdMeshers_NumberOfSegments::SaveTo(ostream & save)
{
save << this->_numberOfSegments << " " << this->_scaleFactor;
return save;
}
//=============================================================================
/*!
*
*/
//=============================================================================
istream & StdMeshers_NumberOfSegments::LoadFrom(istream & load)
{
bool isOK = true;
int a;
isOK = (load >> a);
if (isOK)
this->_numberOfSegments = a;
else
load.clear(ios::badbit | load.rdstate());
double b;
isOK = (load >> b);
if (isOK)
this->_scaleFactor = b;
else
load.clear(ios::badbit | load.rdstate());
return load;
}
//=============================================================================
/*!
*
*/
//=============================================================================
ostream & operator <<(ostream & save, StdMeshers_NumberOfSegments & hyp)
{
return hyp.SaveTo( save );
}
//=============================================================================
/*!
*
*/
//=============================================================================
istream & operator >>(istream & load, StdMeshers_NumberOfSegments & hyp)
{
return hyp.LoadFrom( load );
}

View File

@ -0,0 +1,63 @@
// SMESH SMESH : implementaion of SMESH idl descriptions
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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.
//
// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : StdMeshers_NumberOfSegments.hxx
// Moved here from SMESH_NumberOfSegments.hxx
// Author : Paul RASCLE, EDF
// Module : SMESH
// $Header$
#ifndef _SMESH_NUMBEROFSEGMENTS_HXX_
#define _SMESH_NUMBEROFSEGMENTS_HXX_
#include "SMESH_Hypothesis.hxx"
#include "Utils_SALOME_Exception.hxx"
class StdMeshers_NumberOfSegments:
public SMESH_Hypothesis
{
public:
StdMeshers_NumberOfSegments(int hypId, int studyId, SMESH_Gen* gen);
virtual ~StdMeshers_NumberOfSegments();
void SetNumberOfSegments(int segmentsNumber)
throw (SALOME_Exception);
int GetNumberOfSegments() const;
void SetScaleFactor(double scaleFactor)
throw (SALOME_Exception);
double GetScaleFactor() const;
virtual ostream & SaveTo(ostream & save);
virtual istream & LoadFrom(istream & load);
friend ostream& operator << (ostream & save, StdMeshers_NumberOfSegments & hyp);
friend istream& operator >> (istream & load, StdMeshers_NumberOfSegments & hyp);
protected:
int _numberOfSegments;
double _scaleFactor;
};
#endif

View File

@ -0,0 +1,644 @@
// SMESH SMESH : implementaion of SMESH idl descriptions
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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.
//
// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : StdMeshers_Quadrangle_2D.cxx
// Moved here from SMESH_Quadrangle_2D.cxx
// Author : Paul RASCLE, EDF
// Module : SMESH
// $Header$
using namespace std;
#include "StdMeshers_Quadrangle_2D.hxx"
#include "SMESH_Gen.hxx"
#include "SMESH_Mesh.hxx"
#include "SMDS_MeshElement.hxx"
#include "SMDS_MeshNode.hxx"
#include "SMDS_EdgePosition.hxx"
#include "SMDS_FacePosition.hxx"
#include <BRep_Tool.hxx>
#include <BRepTools.hxx>
#include <BRepTools_WireExplorer.hxx>
#include <Geom_Surface.hxx>
#include <Geom_Curve.hxx>
#include <Geom2d_Curve.hxx>
#include <Handle_Geom2d_Curve.hxx>
#include <Handle_Geom_Curve.hxx>
#include <gp_Pnt2d.hxx>
#include <TColStd_ListIteratorOfListOfInteger.hxx>
#include "utilities.h"
#include "Utils_ExceptHandlers.hxx"
//=============================================================================
/*!
*
*/
//=============================================================================
StdMeshers_Quadrangle_2D::StdMeshers_Quadrangle_2D(int hypId,
int studyId, SMESH_Gen * gen):SMESH_2D_Algo(hypId, studyId, gen)
{
MESSAGE("StdMeshers_Quadrangle_2D::StdMeshers_Quadrangle_2D");
_name = "Quadrangle_2D";
// _shapeType = TopAbs_FACE;
_shapeType = (1 << TopAbs_FACE);
}
//=============================================================================
/*!
*
*/
//=============================================================================
StdMeshers_Quadrangle_2D::~StdMeshers_Quadrangle_2D()
{
MESSAGE("StdMeshers_Quadrangle_2D::~StdMeshers_Quadrangle_2D");
}
//=============================================================================
/*!
*
*/
//=============================================================================
bool StdMeshers_Quadrangle_2D::CheckHypothesis
(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape,
SMESH_Hypothesis::Hypothesis_Status& aStatus)
{
//MESSAGE("StdMeshers_Quadrangle_2D::CheckHypothesis");
bool isOk = true;
aStatus = SMESH_Hypothesis::HYP_OK;
// nothing to check
return isOk;
}
//=============================================================================
/*!
*
*/
//=============================================================================
bool StdMeshers_Quadrangle_2D::Compute(SMESH_Mesh & aMesh,
const TopoDS_Shape & aShape)throw(SALOME_Exception)
{
Unexpect aCatch(SalomeException);
//MESSAGE("StdMeshers_Quadrangle_2D::Compute");
SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
SMESH_subMesh *theSubMesh = aMesh.GetSubMesh(aShape);
FaceQuadStruct *quad = CheckAnd2Dcompute(aMesh, aShape);
if (!quad)
return false;
// --- compute 3D values on points, store points & quadrangles
int nbdown = quad->nbPts[0];
int nbright = quad->nbPts[1];
int nbVertices = nbdown * nbright;
int nbQuad = (nbdown - 1) * (nbright - 1);
//SCRUTE(nbVertices);
//SCRUTE(nbQuad);
// const TopoDS_Face& FF = TopoDS::Face(aShape);
// bool faceIsForward = (FF.Orientation() == TopAbs_FORWARD);
// TopoDS_Face F = TopoDS::Face(FF.Oriented(TopAbs_FORWARD));
const TopoDS_Face & F = TopoDS::Face(aShape);
bool faceIsForward = (F.Orientation() == TopAbs_FORWARD);
Handle(Geom_Surface) S = BRep_Tool::Surface(F);
for (int i = 1; i < nbdown - 1; i++)
for (int j = 1; j < nbright - 1; j++) // internal points
{
int ij = j * nbdown + i;
double u = quad->uv_grid[ij].u;
double v = quad->uv_grid[ij].v;
gp_Pnt P = S->Value(u, v);
SMDS_MeshNode * node = meshDS->AddNode(P.X(), P.Y(), P.Z());
meshDS->SetNodeOnFace(node, F);
quad->uv_grid[ij].node = node;
// Handle (SMDS_FacePosition) fpos
// = new SMDS_FacePosition(theSubMesh->GetId(),i,j); // easier than u,v
// node->SetPosition(fpos);
SMDS_FacePosition* fpos =
dynamic_cast<SMDS_FacePosition*>(node->GetPosition().get());
fpos->SetUParameter(i);
fpos->SetVParameter(j);
}
// bool isQuadForward = ( faceIsForward == quad->isEdgeForward[0]);
for (int i = 0; i < nbdown - 1; i++)
for (int j = 0; j < nbright - 1; j++) // faces
{
const SMDS_MeshNode *a, *b, *c, *d;
a = quad->uv_grid[j * nbdown + i].node;
b = quad->uv_grid[j * nbdown + i + 1].node;
c = quad->uv_grid[(j + 1) * nbdown + i + 1].node;
d = quad->uv_grid[(j + 1) * nbdown + i].node;
// if (isQuadForward) faceId = meshDS->AddFace(a,b,c,d);
// else faceId = meshDS->AddFace(a,d,c,b);
SMDS_MeshFace * face = meshDS->AddFace(a, b, c, d);
meshDS->SetMeshElementOnShape(face, F);
}
QuadDelete(quad);
bool isOk = true;
return isOk;
}
//=============================================================================
/*!
*
*/
//=============================================================================
FaceQuadStruct *StdMeshers_Quadrangle_2D::CheckAnd2Dcompute(SMESH_Mesh & aMesh,
const TopoDS_Shape & aShape)throw(SALOME_Exception)
{
Unexpect aCatch(SalomeException);
//MESSAGE("StdMeshers_Quadrangle_2D::ComputeWithoutStore");
SMESH_subMesh *theSubMesh = aMesh.GetSubMesh(aShape);
// const TopoDS_Face& FF = TopoDS::Face(aShape);
// bool faceIsForward = (FF.Orientation() == TopAbs_FORWARD);
// TopoDS_Face F = TopoDS::Face(FF.Oriented(TopAbs_FORWARD));
const TopoDS_Face & F = TopoDS::Face(aShape);
bool faceIsForward = (F.Orientation() == TopAbs_FORWARD);
// verify 1 wire only, with 4 edges, same number of points on opposite edges
if (NumberOfWires(F) != 1)
{
MESSAGE("only 1 wire by face (quadrangles)");
return 0;
//throw SALOME_Exception(LOCALIZED("only 1 wire by face (quadrangles)"));
}
// const TopoDS_Wire WW = BRepTools::OuterWire(F);
// TopoDS_Wire W = TopoDS::Wire(WW.Oriented(TopAbs_FORWARD));
const TopoDS_Wire & W = BRepTools::OuterWire(F);
BRepTools_WireExplorer wexp(W, F);
FaceQuadStruct *quad = new FaceQuadStruct;
for (int i = 0; i < 4; i++)
quad->uv_edges[i] = 0;
quad->uv_grid = 0;
int nbEdges = 0;
for (wexp.Init(W, F); wexp.More(); wexp.Next())
{
// const TopoDS_Edge& EE = wexp.Current();
// TopoDS_Edge E = TopoDS::Edge(EE.Oriented(TopAbs_FORWARD));
const TopoDS_Edge & E = wexp.Current();
int nb = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
if (nbEdges < 4)
{
quad->edge[nbEdges] = E;
quad->nbPts[nbEdges] = nb + 2; // internal points + 2 extrema
}
nbEdges++;
}
if (nbEdges != 4)
{
MESSAGE("face must have 4 edges /quadrangles");
QuadDelete(quad);
return 0;
//throw SALOME_Exception(LOCALIZED("face must have 4 edges /quadrangles"));
}
if (quad->nbPts[0] != quad->nbPts[2])
{
MESSAGE("different point number-opposed edge");
QuadDelete(quad);
return 0;
//throw SALOME_Exception(LOCALIZED("different point number-opposed edge"));
}
if (quad->nbPts[1] != quad->nbPts[3])
{
MESSAGE("different point number-opposed edge");
QuadDelete(quad);
return 0;
//throw SALOME_Exception(LOCALIZED("different point number-opposed edge"));
}
// set normalized grid on unit square in parametric domain
SetNormalizedGrid(aMesh, F, quad);
return quad;
}
//=============================================================================
/*!
*
*/
//=============================================================================
void StdMeshers_Quadrangle_2D::QuadDelete(FaceQuadStruct * quad)
{
//MESSAGE("StdMeshers_Quadrangle_2D::QuadDelete");
if (quad)
{
for (int i = 0; i < 4; i++)
{
if (quad->uv_edges[i])
delete[]quad->uv_edges[i];
quad->edge[i].Nullify();
}
if (quad->uv_grid)
delete[]quad->uv_grid;
delete quad;
}
}
//=============================================================================
/*!
*
*/
//=============================================================================
void StdMeshers_Quadrangle_2D::SetNormalizedGrid(SMESH_Mesh & aMesh,
const TopoDS_Shape & aShape, FaceQuadStruct * quad) throw(SALOME_Exception)
{
Unexpect aCatch(SalomeException);
// Algorithme décrit dans "Génération automatique de maillages"
// P.L. GEORGE, MASSON, § 6.4.1 p. 84-85
// traitement dans le domaine paramétrique 2d u,v
// transport - projection sur le carré unité
const TopoDS_Face & F = TopoDS::Face(aShape);
// 1 --- find orientation of the 4 edges, by test on extrema
// max min 0 x1 1
// |<----north-2-------^ a3 -------------> a2
// | | ^1 1^
// west-3 east-1 =right | |
// | | ==> | |
// y0 | | y1 | |
// | | |0 0|
// v----south-0--------> a0 -------------> a1
// min max 0 x0 1
// =down
//
Handle(Geom2d_Curve) c2d[4];
gp_Pnt2d pf[4];
gp_Pnt2d pl[4];
for (int i = 0; i < 4; i++)
{
c2d[i] = BRep_Tool::CurveOnSurface(quad->edge[i],
F, quad->first[i], quad->last[i]);
pf[i] = c2d[i]->Value(quad->first[i]);
pl[i] = c2d[i]->Value(quad->last[i]);
quad->isEdgeForward[i] = false;
}
double eps2d = 1.e-3; // *** utiliser plutot TopExp::CommonVertex, puis
// distances si piece fausse
int i = 0;
if ((pf[1].Distance(pl[0]) < eps2d) || (pl[1].Distance(pl[0]) < eps2d))
{
quad->isEdgeForward[0] = true;
}
else
{
double tmp = quad->first[0];
quad->first[0] = quad->last[0];
quad->last[0] = tmp;
pf[0] = c2d[0]->Value(quad->first[0]);
pl[0] = c2d[0]->Value(quad->last[0]);
}
for (int i = 1; i < 4; i++)
{
quad->isEdgeForward[i] = (pf[i].Distance(pl[i - 1]) < eps2d);
if (!quad->isEdgeForward[i])
{
double tmp = quad->first[i];
quad->first[i] = quad->last[i];
quad->last[i] = tmp;
pf[i] = c2d[i]->Value(quad->first[i]);
pl[i] = c2d[i]->Value(quad->last[i]);
//SCRUTE(pf[i].Distance(pl[i-1]));
ASSERT(pf[i].Distance(pl[i - 1]) < eps2d);
}
}
//SCRUTE(pf[0].Distance(pl[3]));
ASSERT(pf[0].Distance(pl[3]) < eps2d);
// for (int i=0; i<4; i++)
// {
// SCRUTE(quad->isEdgeForward[i]);
// MESSAGE(" -first "<<i<<" "<<pf[i].X()<<" "<<pf[i].Y());
// MESSAGE(" -last "<<i<<" "<<pl[i].X()<<" "<<pl[i].Y());
// }
// 2 --- load 2d edge points (u,v) with orientation and value on unit square
for (int i = 0; i < 2; i++)
{
quad->uv_edges[i] = LoadEdgePoints(aMesh, F,
quad->edge[i], quad->first[i], quad->last[i]);
// quad->isEdgeForward[i]);
}
for (int i = 2; i < 4; i++)
{
quad->uv_edges[i] = LoadEdgePoints(aMesh, F,
quad->edge[i], quad->last[i], quad->first[i]);
// !quad->isEdgeForward[i]);
}
// 3 --- 2D normalized values on unit square [0..1][0..1]
int nbdown = quad->nbPts[0];
int nbright = quad->nbPts[1];
quad->uv_grid = new UVPtStruct[nbright * nbdown];
UVPtStruct *uv_grid = quad->uv_grid;
UVPtStruct *uv_e0 = quad->uv_edges[0];
UVPtStruct *uv_e1 = quad->uv_edges[1];
UVPtStruct *uv_e2 = quad->uv_edges[2];
UVPtStruct *uv_e3 = quad->uv_edges[3];
gp_Pnt2d a0 = pf[0];
gp_Pnt2d a1 = pf[1];
gp_Pnt2d a2 = pf[2];
gp_Pnt2d a3 = pf[3];
// nodes Id on edges
int j = 0;
for (int i = 0; i < nbdown; i++)
{
int ij = j * nbdown + i;
uv_grid[ij].node = uv_e0[i].node;
}
i = nbdown - 1;
for (int j = 0; j < nbright; j++)
{
int ij = j * nbdown + i;
uv_grid[ij].node = uv_e1[j].node;
}
j = nbright - 1;
for (int i = 0; i < nbdown; i++)
{
int ij = j * nbdown + i;
uv_grid[ij].node = uv_e2[i].node;
}
i = 0;
for (int j = 0; j < nbright; j++)
{
int ij = j * nbdown + i;
uv_grid[ij].node = uv_e3[j].node;
}
// normalized 2d values on grid
for (int i = 0; i < nbdown; i++)
for (int j = 0; j < nbright; j++)
{
int ij = j * nbdown + i;
// --- droite i cste : x = x0 + y(x1-x0)
double x0 = uv_e0[i].normParam; // bas - sud
double x1 = uv_e2[i].normParam; // haut - nord
// --- droite j cste : y = y0 + x(y1-y0)
double y0 = uv_e3[j].normParam; // gauche-ouest
double y1 = uv_e1[j].normParam; // droite - est
// --- intersection : x=x0+(y0+x(y1-y0))(x1-x0)
double x = (x0 + y0 * (x1 - x0)) / (1 - (y1 - y0) * (x1 - x0));
double y = y0 + x * (y1 - y0);
uv_grid[ij].x = x;
uv_grid[ij].y = y;
//MESSAGE("-xy-01 "<<x0<<" "<<x1<<" "<<y0<<" "<<y1);
//MESSAGE("-xy-norm "<<i<<" "<<j<<" "<<x<<" "<<y);
}
// 4 --- projection on 2d domain (u,v)
for (int i = 0; i < nbdown; i++)
for (int j = 0; j < nbright; j++)
{
int ij = j * nbdown + i;
double x = uv_grid[ij].x;
double y = uv_grid[ij].y;
double param_0 = uv_e0[0].param + x * (uv_e0[nbdown - 1].param - uv_e0[0].param); // sud
double param_2 = uv_e2[0].param + x * (uv_e2[nbdown - 1].param - uv_e2[0].param); // nord
double param_1 = uv_e1[0].param + y * (uv_e1[nbright - 1].param - uv_e1[0].param); // est
double param_3 = uv_e3[0].param + y * (uv_e3[nbright - 1].param - uv_e3[0].param); // ouest
//MESSAGE("params "<<param_0<<" "<<param_1<<" "<<param_2<<" "<<param_3);
gp_Pnt2d p0 = c2d[0]->Value(param_0);
gp_Pnt2d p1 = c2d[1]->Value(param_1);
gp_Pnt2d p2 = c2d[2]->Value(param_2);
gp_Pnt2d p3 = c2d[3]->Value(param_3);
double u =
(1 - y) * p0.X() + x * p1.X() + y * p2.X() + (1 - x) * p3.X();
double v =
(1 - y) * p0.Y() + x * p1.Y() + y * p2.Y() + (1 - x) * p3.Y();
u -= (1 - x) * (1 - y) * a0.X() + x * (1 - y) * a1.X() +
x * y * a2.X() + (1 - x) * y * a3.X();
v -= (1 - x) * (1 - y) * a0.Y() + x * (1 - y) * a1.Y() +
x * y * a2.Y() + (1 - x) * y * a3.Y();
uv_grid[ij].u = u;
uv_grid[ij].v = v;
//MESSAGE("-uv- "<<i<<" "<<j<<" "<<uv_grid[ij].u<<" "<<uv_grid[ij].v);
}
}
//=============================================================================
/*!
*
*/
//=============================================================================
UVPtStruct *StdMeshers_Quadrangle_2D::LoadEdgePoints(SMESH_Mesh & aMesh,
const TopoDS_Face & F, const TopoDS_Edge & E, double first, double last)
// bool isForward)
{
//MESSAGE("StdMeshers_Quadrangle_2D::LoadEdgePoints");
SMDS_Mesh * meshDS = aMesh.GetMeshDS();
// --- IDNodes of first and last Vertex
TopoDS_Vertex VFirst, VLast;
TopExp::Vertices(E, VFirst, VLast); // corresponds to f and l
ASSERT(!VFirst.IsNull());
SMDS_NodeIteratorPtr lid= aMesh.GetSubMesh(VFirst)->GetSubMeshDS()->GetNodes();
const SMDS_MeshNode * idFirst = lid->next();
ASSERT(!VLast.IsNull());
lid=aMesh.GetSubMesh(VLast)->GetSubMeshDS()->GetNodes();
const SMDS_MeshNode * idLast = lid->next();
// --- edge internal IDNodes (relies on good order storage, not checked)
int nbPoints = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
//SCRUTE(nbPoints);
UVPtStruct *uvslf = new UVPtStruct[nbPoints + 2];
double f, l;
Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E, F, f, l);
map<double, const SMDS_MeshNode *> params;
SMDS_NodeIteratorPtr ite= aMesh.GetSubMesh(E)->GetSubMeshDS()->GetNodes();
while(ite->more())
{
const SMDS_MeshNode * node = ite->next();
const SMDS_EdgePosition* epos =
static_cast<const SMDS_EdgePosition*>(node->GetPosition().get());
double param = epos->GetUParameter();
params[param] = node;
}
bool isForward = (((l - f) * (last - first)) > 0);
double paramin = 0;
double paramax = 0;
if (isForward)
{
paramin = f;
paramax = l;
gp_Pnt2d p = C2d->Value(f); // first point = Vertex Forward
uvslf[0].x = p.X();
uvslf[0].y = p.Y();
uvslf[0].param = f;
uvslf[0].node = idFirst;
//MESSAGE("__ f "<<f<<" "<<uvslf[0].x <<" "<<uvslf[0].y);
map < double, const SMDS_MeshNode* >::iterator itp = params.begin();
for (int i = 1; i <= nbPoints; i++) // nbPoints internal
{
double param = (*itp).first;
gp_Pnt2d p = C2d->Value(param);
uvslf[i].x = p.X();
uvslf[i].y = p.Y();
uvslf[i].param = param;
uvslf[i].node = (*itp).second;
//MESSAGE("__ "<<i<<" "<<param<<" "<<uvslf[i].x <<" "<<uvslf[i].y);
itp++;
}
p = C2d->Value(l); // last point = Vertex Reversed
uvslf[nbPoints + 1].x = p.X();
uvslf[nbPoints + 1].y = p.Y();
uvslf[nbPoints + 1].param = l;
uvslf[nbPoints + 1].node = idLast;
//MESSAGE("__ l "<<l<<" "<<uvslf[nbPoints+1].x <<" "<<uvslf[nbPoints+1].y);
}
else
{
paramin = l;
paramax = f;
gp_Pnt2d p = C2d->Value(l); // first point = Vertex Reversed
uvslf[0].x = p.X();
uvslf[0].y = p.Y();
uvslf[0].param = l;
uvslf[0].node = idLast;
//MESSAGE("__ l "<<l<<" "<<uvslf[0].x <<" "<<uvslf[0].y);
map < double, const SMDS_MeshNode* >::reverse_iterator itp = params.rbegin();
for (int j = nbPoints; j >= 1; j--) // nbPoints internal
{
double param = (*itp).first;
int i = nbPoints + 1 - j;
gp_Pnt2d p = C2d->Value(param);
uvslf[i].x = p.X();
uvslf[i].y = p.Y();
uvslf[i].param = param;
uvslf[i].node = (*itp).second;
//MESSAGE("__ "<<i<<" "<<param<<" "<<uvslf[i].x <<" "<<uvslf[i].y);
itp++;
}
p = C2d->Value(f); // last point = Vertex Forward
uvslf[nbPoints + 1].x = p.X();
uvslf[nbPoints + 1].y = p.Y();
uvslf[nbPoints + 1].param = f;
uvslf[nbPoints + 1].node = idFirst;
//MESSAGE("__ f "<<f<<" "<<uvslf[nbPoints+1].x <<" "<<uvslf[nbPoints+1].y);
}
ASSERT(paramin != paramax);
for (int i = 0; i < nbPoints + 2; i++)
{
uvslf[i].normParam = (uvslf[i].param - paramin) / (paramax - paramin);
//SCRUTE(uvslf[i].normParam);
}
return uvslf;
}
//=============================================================================
/*!
*
*/
//=============================================================================
ostream & StdMeshers_Quadrangle_2D::SaveTo(ostream & save)
{
return save;
}
//=============================================================================
/*!
*
*/
//=============================================================================
istream & StdMeshers_Quadrangle_2D::LoadFrom(istream & load)
{
return load;
}
//=============================================================================
/*!
*
*/
//=============================================================================
ostream & operator <<(ostream & save, StdMeshers_Quadrangle_2D & hyp)
{
return hyp.SaveTo( save );
}
//=============================================================================
/*!
*
*/
//=============================================================================
istream & operator >>(istream & load, StdMeshers_Quadrangle_2D & hyp)
{
return hyp.LoadFrom( load );
}

View File

@ -0,0 +1,102 @@
// SMESH SMESH : implementaion of SMESH idl descriptions
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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.
//
// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : StdMeshers_Quadrangle_2D.hxx
// Moved here from SMESH_Quadrangle_2D.hxx
// Author : Paul RASCLE, EDF
// Module : SMESH
// $Header$
#ifndef _SMESH_QUADRANGLE_2D_HXX_
#define _SMESH_QUADRANGLE_2D_HXX_
#include "SMESH_2D_Algo.hxx"
#include "SMESH_Mesh.hxx"
#include "Utils_SALOME_Exception.hxx"
typedef struct uvPtStruct
{
double param;
double normParam;
double u; // original 2d parameter
double v;
double x; // 2d parameter, normalized [0,1]
double y;
const SMDS_MeshNode * node;
} UVPtStruct;
typedef struct faceQuadStruct
{
int nbPts[4];
TopoDS_Edge edge[4];
double first[4];
double last[4];
bool isEdgeForward[4];
UVPtStruct* uv_edges[4];
UVPtStruct* uv_grid;
} FaceQuadStruct;
class StdMeshers_Quadrangle_2D:
public SMESH_2D_Algo
{
public:
StdMeshers_Quadrangle_2D(int hypId, int studyId, SMESH_Gen* gen);
virtual ~StdMeshers_Quadrangle_2D();
virtual bool CheckHypothesis(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape,
SMESH_Hypothesis::Hypothesis_Status& aStatus);
virtual bool Compute(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape)
throw (SALOME_Exception);
FaceQuadStruct* CheckAnd2Dcompute(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape)
throw (SALOME_Exception);
void QuadDelete(FaceQuadStruct* quad);
ostream & SaveTo(ostream & save);
istream & LoadFrom(istream & load);
friend ostream & operator << (ostream & save, StdMeshers_Quadrangle_2D & hyp);
friend istream & operator >> (istream & load, StdMeshers_Quadrangle_2D & hyp);
protected:
void SetNormalizedGrid(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape,
FaceQuadStruct* quad)
throw (SALOME_Exception);
UVPtStruct* LoadEdgePoints(SMESH_Mesh& aMesh,
const TopoDS_Face& F,
const TopoDS_Edge& E,
double first,
double last);
// bool isForward);
// FaceQuadStruct _quadDesc;
};
#endif

View File

@ -0,0 +1,331 @@
// SMESH SMESH : implementaion of SMESH idl descriptions
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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.
//
// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : StdMeshers_Regular_1D.cxx
// Moved here from SMESH_Regular_1D.cxx
// Author : Paul RASCLE, EDF
// Module : SMESH
// $Header$
using namespace std;
#include "StdMeshers_Regular_1D.hxx"
#include "SMESH_Gen.hxx"
#include "SMESH_Mesh.hxx"
#include "StdMeshers_LocalLength.hxx"
#include "StdMeshers_NumberOfSegments.hxx"
#include "SMDS_MeshElement.hxx"
#include "SMDS_MeshNode.hxx"
#include "SMDS_EdgePosition.hxx"
#include "utilities.h"
#include <TopoDS_Edge.hxx>
#include <TopoDS_Shape.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <BRep_Tool.hxx>
#include <GCPnts_AbscissaPoint.hxx>
#include <GCPnts_UniformAbscissa.hxx>
#include <string>
#include <algorithm>
//=============================================================================
/*!
*
*/
//=============================================================================
StdMeshers_Regular_1D::StdMeshers_Regular_1D(int hypId, int studyId,
SMESH_Gen * gen):SMESH_1D_Algo(hypId, studyId, gen)
{
MESSAGE("StdMeshers_Regular_1D::StdMeshers_Regular_1D");
_name = "Regular_1D";
// _shapeType = TopAbs_EDGE;
_shapeType = (1 << TopAbs_EDGE);
_compatibleHypothesis.push_back("LocalLength");
_compatibleHypothesis.push_back("NumberOfSegments");
_localLength = 0;
_numberOfSegments = 0;
_hypLocalLength = NULL;
_hypNumberOfSegments = NULL;
}
//=============================================================================
/*!
*
*/
//=============================================================================
StdMeshers_Regular_1D::~StdMeshers_Regular_1D()
{
}
//=============================================================================
/*!
*
*/
//=============================================================================
bool StdMeshers_Regular_1D::CheckHypothesis
(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape,
SMESH_Hypothesis::Hypothesis_Status& aStatus)
{
//MESSAGE("StdMeshers_Regular_1D::CheckHypothesis");
list <const SMESHDS_Hypothesis * >::const_iterator itl;
const SMESHDS_Hypothesis *theHyp;
const list <const SMESHDS_Hypothesis * >&hyps = GetUsedHypothesis(aMesh, aShape);
int nbHyp = hyps.size();
if (!nbHyp)
{
aStatus = SMESH_Hypothesis::HYP_MISSING;
return false; // can't work with no hypothesis
}
itl = hyps.begin();
theHyp = (*itl); // use only the first hypothesis
string hypName = theHyp->GetName();
int hypId = theHyp->GetID();
//SCRUTE(hypName);
bool isOk = false;
if (hypName == "LocalLength")
{
_hypLocalLength = dynamic_cast <const StdMeshers_LocalLength * >(theHyp);
ASSERT(_hypLocalLength);
_localLength = _hypLocalLength->GetLength();
_numberOfSegments = 0;
isOk = true;
aStatus = SMESH_Hypothesis::HYP_OK;
}
else if (hypName == "NumberOfSegments")
{
_hypNumberOfSegments =
dynamic_cast <const StdMeshers_NumberOfSegments * >(theHyp);
ASSERT(_hypNumberOfSegments);
_numberOfSegments = _hypNumberOfSegments->GetNumberOfSegments();
_scaleFactor = _hypNumberOfSegments->GetScaleFactor();
_localLength = 0;
isOk = true;
aStatus = SMESH_Hypothesis::HYP_OK;
}
else
aStatus = SMESH_Hypothesis::HYP_INCOMPATIBLE;
//SCRUTE(_localLength);
//SCRUTE(_numberOfSegments);
return isOk;
}
//=============================================================================
/*!
*
*/
//=============================================================================
bool StdMeshers_Regular_1D::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
{
MESSAGE("StdMeshers_Regular_1D::Compute");
SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
SMESH_subMesh *theSubMesh = aMesh.GetSubMesh(aShape);
const TopoDS_Edge & EE = TopoDS::Edge(aShape);
TopoDS_Edge E = TopoDS::Edge(EE.Oriented(TopAbs_FORWARD));
double f, l;
Handle(Geom_Curve) Curve = BRep_Tool::Curve(E, f, l);
TopoDS_Vertex VFirst, VLast;
TopExp::Vertices(E, VFirst, VLast); // Vfirst corresponds to f and Vlast to l
double length = EdgeLength(E);
//SCRUTE(length);
double eltSize = 1;
// if (_localLength > 0) eltSize = _localLength;
if (_localLength > 0)
{
double nbseg = ceil(length / _localLength); // integer sup
if (nbseg <= 0)
nbseg = 1; // degenerated edge
eltSize = length / nbseg;
}
else
{
ASSERT(_numberOfSegments > 0);
eltSize = length / _numberOfSegments;
}
ASSERT(!VFirst.IsNull());
SMDS_NodeIteratorPtr lid= aMesh.GetSubMesh(VFirst)->GetSubMeshDS()->GetNodes();
const SMDS_MeshNode * idFirst = lid->next();
ASSERT(!VLast.IsNull());
lid=aMesh.GetSubMesh(VLast)->GetSubMeshDS()->GetNodes();
const SMDS_MeshNode * idLast = lid->next();
if (!Curve.IsNull())
{
GeomAdaptor_Curve C3d(Curve);
GCPnts_UniformAbscissa Discret(C3d, eltSize, f, l);
int NbPoints = Discret.NbPoints();
//MESSAGE("nb points on edge : "<<NbPoints);
// edge extrema (indexes : 1 & NbPoints) already in SMDS (TopoDS_Vertex)
// only internal nodes receive an edge position with param on curve
const SMDS_MeshNode * idPrev = idFirst;
for (int i = 2; i < NbPoints; i++)
{
double param = Discret.Parameter(i);
if (_numberOfSegments > 1)
{
double epsilon = 0.001;
if (fabs(_scaleFactor - 1.0) > epsilon)
{
double alpha =
pow(_scaleFactor, 1.0 / (_numberOfSegments - 1));
double d =
length * (1 - pow(alpha, i - 1)) / (1 - pow(alpha,
_numberOfSegments));
param = d;
}
}
gp_Pnt P = Curve->Value(param);
//Add the Node in the DataStructure
//MESSAGE("point "<<nodeId<<" "<<P.X()<<" "<<P.Y()<<" "<<P.Z()<<" - "<<i<<" "<<param);
SMDS_MeshNode * node = meshDS->AddNode(P.X(), P.Y(), P.Z());
meshDS->SetNodeOnEdge(node, E);
// **** edgePosition associe au point = param.
SMDS_EdgePosition* epos =
dynamic_cast<SMDS_EdgePosition *>(node->GetPosition().get());
epos->SetUParameter(param);
SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, node);
meshDS->SetMeshElementOnShape(edge, E);
idPrev = node;
}
SMDS_MeshEdge* edge = meshDS->AddEdge(idPrev, idLast);
meshDS->SetMeshElementOnShape(edge, E);
}
else
{
// MESSAGE ("Edge Degeneree non traitee --- arret");
// ASSERT(0);
if (BRep_Tool::Degenerated(E))
{
// Edge is a degenerated Edge : We put n = 5 points on the edge.
int NbPoints = 5;
BRep_Tool::Range(E, f, l);
double du = (l - f) / (NbPoints - 1);
MESSAGE("************* Degenerated edge! *****************");
TopoDS_Vertex V1, V2;
TopExp::Vertices(E, V1, V2);
gp_Pnt P = BRep_Tool::Pnt(V1);
const SMDS_MeshNode * idPrev = idFirst;
for (int i = 2; i < NbPoints; i++)
{
double param = f + (i - 1) * du;
SMDS_MeshNode * node = meshDS->AddNode(P.X(), P.Y(), P.Z());
meshDS->SetNodeOnEdge(node, E);
// Handle (SMDS_EdgePosition) epos
// = new SMDS_EdgePosition(theSubMesh->GetId(),param);
// node->SetPosition(epos);
SMDS_EdgePosition* epos =
dynamic_cast<SMDS_EdgePosition*>(node->GetPosition().get());
epos->SetUParameter(param);
SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, node);
meshDS->SetMeshElementOnShape(edge, E);
idPrev = node;
}
SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, idLast);
meshDS->SetMeshElementOnShape(edge, E);
}
else
ASSERT(0);
}
return true;
}
//=============================================================================
/*!
*
*/
//=============================================================================
ostream & StdMeshers_Regular_1D::SaveTo(ostream & save)
{
return save;
}
//=============================================================================
/*!
*
*/
//=============================================================================
istream & StdMeshers_Regular_1D::LoadFrom(istream & load)
{
return load;
}
//=============================================================================
/*!
*
*/
//=============================================================================
ostream & operator <<(ostream & save, StdMeshers_Regular_1D & hyp)
{
return hyp.SaveTo( save );
}
//=============================================================================
/*!
*
*/
//=============================================================================
istream & operator >>(istream & load, StdMeshers_Regular_1D & hyp)
{
return hyp.LoadFrom( load );
}

View File

@ -0,0 +1,65 @@
// SMESH SMESH : implementaion of SMESH idl descriptions
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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.
//
// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : StdMeshers_Regular_1D.hxx
// Moved here from SMESH_Regular_1D.hxx
// Author : Paul RASCLE, EDF
// Module : SMESH
// $Header$
#ifndef _SMESH_REGULAR_1D_HXX_
#define _SMESH_REGULAR_1D_HXX_
#include "SMESH_1D_Algo.hxx"
class StdMeshers_LocalLength;
class StdMeshers_NumberOfSegments;
class StdMeshers_Regular_1D:
public SMESH_1D_Algo
{
public:
StdMeshers_Regular_1D(int hypId, int studyId, SMESH_Gen* gen);
virtual ~StdMeshers_Regular_1D();
virtual bool CheckHypothesis(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape,
SMESH_Hypothesis::Hypothesis_Status& aStatus);
virtual bool Compute(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape);
ostream & SaveTo(ostream & save);
istream & LoadFrom(istream & load);
friend ostream & operator << (ostream & save, StdMeshers_Regular_1D & hyp);
friend istream & operator >> (istream & load, StdMeshers_Regular_1D & hyp);
protected:
double _localLength;
int _numberOfSegments;
double _scaleFactor;
const StdMeshers_LocalLength* _hypLocalLength;
const StdMeshers_NumberOfSegments* _hypNumberOfSegments;
};
#endif

View File

@ -0,0 +1,78 @@
# SMESH StdMeshersGUI : GUI for StdMeshers plugin
#
# Copyright (C) 2003 CEA
#
# 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.
#
# 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.org
#
#
#
# File : Makefile.in
# Author : Julia DOROVSKIKH
# Module : SMESH
# $Header$
top_srcdir=@top_srcdir@
top_builddir=../..
srcdir=@srcdir@
VPATH=.:@srcdir@:@top_srcdir@/idl:$(top_builddir)/idl:${KERNEL_ROOT_DIR}/idl/salome:${MED_ROOT_DIR}/idl/salome
@COMMENCE@
# .po files to transform in .qm
PO_FILES = \
StdMeshers_icons.po \
StdMeshers_msg_en.po
# Libraries targets
LIB = libStdMeshersGUI.la
LIB_SRC = \
StdMeshersGUI.cxx \
StdMeshersGUI_LocalLengthDlg.cxx \
StdMeshersGUI_NbSegmentsDlg.cxx \
StdMeshersGUI_MaxElementAreaDlg.cxx \
StdMeshersGUI_MaxElementVolumeDlg.cxx
LIB_MOC = \
StdMeshersGUI_LocalLengthDlg.h \
StdMeshersGUI_NbSegmentsDlg.h \
StdMeshersGUI_MaxElementAreaDlg.h \
StdMeshersGUI_MaxElementVolumeDlg.h
LIB_CLIENT_IDL = \
SALOME_Exception.idl \
SMESH_Gen.idl \
SMESH_Mesh.idl \
SMESH_Group.idl \
SMESH_Filter.idl \
SMESH_Hypothesis.idl \
SMESH_BasicHypothesis.idl \
MED.idl
LIB_SERVER_IDL =
# additionnal information to compil and link file
CPPFLAGS += $(QT_INCLUDES) $(VTK_INCLUDES) $(OGL_INCLUDES) $(OCC_INCLUDES) $(PYTHON_INCLUDES) \
$(MED2_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome -I${GEOM_ROOT_DIR}/include/salome \
$(BOOST_CPPFLAGS)
CXXFLAGS += -I${KERNEL_ROOT_DIR}/include/salome -I${GEOM_ROOT_DIR}/include/salome
#$(OCC_CXXFLAGS)
LDFLAGS += -lSMESHGUI $(OCC_KERNEL_LIBS) -L${KERNEL_ROOT_DIR}/lib/salome -L${GEOM_ROOT_DIR}/lib/salome
@CONCLUDE@

View File

@ -0,0 +1,225 @@
// SMESH StdMeshersGUI : GUI for plugged-in meshers
//
// Copyright (C) 2003 CEA
//
// 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.
//
// 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.org
//
//
//
// File : StdMeshersGUI.cxx
// Author : Julia DOROVSKIKH
// Module : SMESH
// $Header$
using namespace std;
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
#include "SMESHGUI.h"
#include "SMESHGUI_Hypotheses.h"
#include "StdMeshersGUI_LocalLengthDlg.h"
#include "StdMeshersGUI_NbSegmentsDlg.h"
#include "StdMeshersGUI_MaxElementAreaDlg.h"
#include "StdMeshersGUI_MaxElementVolumeDlg.h"
#include "QAD_Desktop.h"
#include "QAD_ResourceMgr.h"
#include <qobject.h>
//=============================================================================
/*! class HypothesisCreator
*
*/
//=============================================================================
class StdMeshersGUI_HypothesisCreator : public SMESHGUI_GenericHypothesisCreator
{
public:
StdMeshersGUI_HypothesisCreator (const QString& aHypType,
const QString& aServerLibName,
SMESHGUI* aSMESHGUI)
: myHypType(aHypType),
myServerLibName(aServerLibName),
mySMESHGUI(aSMESHGUI) {}
virtual void CreateHypothesis (const bool isAlgo, QWidget* parent = 0);
virtual void EditHypothesis (SMESH::SMESH_Hypothesis_ptr theHyp);
private:
QString myHypType;
QString myServerLibName;
SMESHGUI* mySMESHGUI;
};
//=============================================================================
/*! HypothesisCreator::CreateHypothesis
*
*/
//=============================================================================
void StdMeshersGUI_HypothesisCreator::CreateHypothesis
(bool isAlgo, QWidget* parent)
{
MESSAGE("StdMeshersGUI_HypothesisCreator::CreateHypothesis");
// Get default name for hypothesis/algorithm creation
char* sHypType = (char*)myHypType.latin1();
HypothesisData* aHypData = mySMESHGUI->GetHypothesisData(sHypType);
QString aHypName;
if (aHypData)
aHypName = aHypData->Label;
else
aHypName = myHypType;
// Create hypothesis/algorithm
if (isAlgo)
{
mySMESHGUI->CreateHypothesis(myHypType, aHypName, isAlgo);
}
else
{
// Show Dialog for hypothesis creation
if (myHypType == "LocalLength")
StdMeshersGUI_LocalLengthDlg *aDlg = new StdMeshersGUI_LocalLengthDlg(myHypType, parent, "");
else if (myHypType == "NumberOfSegments")
StdMeshersGUI_NbSegmentsDlg *aDlg = new StdMeshersGUI_NbSegmentsDlg(myHypType, parent, "");
else if (myHypType == "MaxElementArea")
StdMeshersGUI_MaxElementAreaDlg *aDlg = new StdMeshersGUI_MaxElementAreaDlg(myHypType, parent, "");
else if (myHypType == "MaxElementVolume")
StdMeshersGUI_MaxElementVolumeDlg *aDlg = new StdMeshersGUI_MaxElementVolumeDlg(myHypType, parent, "");
else if (myHypType == "LengthFromEdges")
mySMESHGUI->CreateHypothesis(myHypType, aHypName, isAlgo); // without GUI
else if (myHypType == "NotConformAllowed")
mySMESHGUI->CreateHypothesis(myHypType, aHypName, isAlgo); // without GUI
else ;
}
}
//=============================================================================
/*! HypothesisCreator::EditHypothesis
*
*/
//=============================================================================
void StdMeshersGUI_HypothesisCreator::EditHypothesis
(SMESH::SMESH_Hypothesis_ptr theHyp)
{
MESSAGE("StdMeshersGUI_HypothesisCreator::EditHypothesis");
Standard_Boolean res = Standard_True;
SALOMEDS::Study::ListOfSObject_var listSOmesh =
mySMESHGUI->GetMeshesUsingAlgoOrHypothesis(theHyp);
QString Name = theHyp->GetName();
if (Name.compare("LocalLength") == 0)
{
StdMeshers::StdMeshers_LocalLength_var LL =
StdMeshers::StdMeshers_LocalLength::_narrow(theHyp);
double beforeLength = LL->GetLength() ;
double Length = mySMESHGUI->Parameter(res,
beforeLength,
QObject::tr("SMESH_LOCAL_LENGTH_HYPOTHESIS"),
QObject::tr("SMESH_VALUE"),
1.0E-5, 1E6, 6);
if (res && Length != beforeLength)
{
LL->SetLength(Length);
for (int i=0; i<listSOmesh->length(); i++)
{
mySMESHGUI->GetStudyAPI().ModifiedMesh(listSOmesh[i], false);
}
}
}
else if (Name.compare("NumberOfSegments") == 0)
{
StdMeshers::StdMeshers_NumberOfSegments_var NOS =
StdMeshers::StdMeshers_NumberOfSegments::_narrow(theHyp);
int beforeNbSeg = NOS->GetNumberOfSegments() ;
int NbSeg = mySMESHGUI->Parameter(res,
beforeNbSeg,
QObject::tr("SMESH_NB_SEGMENTS_HYPOTHESIS"),
QObject::tr("SMESH_VALUE"),
1, 1000000);
if (res && NbSeg != beforeNbSeg)
{
NOS->SetNumberOfSegments(NbSeg);
for (int i=0; i<listSOmesh->length(); i++)
{
SALOMEDS::SObject_var SO = listSOmesh[i] ;
mySMESHGUI->GetStudyAPI().ModifiedMesh(listSOmesh[i], false);
}
}
}
else if (Name.compare("MaxElementArea") == 0)
{
StdMeshers::StdMeshers_MaxElementArea_var MEA =
StdMeshers::StdMeshers_MaxElementArea::_narrow(theHyp);
double beforeMaxArea = MEA->GetMaxElementArea();
double MaxArea = mySMESHGUI->Parameter(res,
beforeMaxArea,
QObject::tr("SMESH_MAX_ELEMENT_AREA_HYPOTHESIS"),
QObject::tr("SMESH_VALUE"),
1.0E-5, 1E6, 6);
if (res && MaxArea != beforeMaxArea)
{
MEA->SetMaxElementArea(MaxArea);
for (int i=0; i<listSOmesh->length(); i++)
{
mySMESHGUI->GetStudyAPI().ModifiedMesh(listSOmesh[i], false);
}
}
}
else if (Name.compare("MaxElementVolume") == 0)
{
StdMeshers::StdMeshers_MaxElementVolume_var MEV =
StdMeshers::StdMeshers_MaxElementVolume::_narrow(theHyp);
double beforeMaxVolume = MEV->GetMaxElementVolume() ;
double MaxVolume = mySMESHGUI->Parameter(res,
beforeMaxVolume,
QObject::tr("SMESH_MAX_ELEMENT_VOLUME_HYPOTHESIS"),
QObject::tr("SMESH_VALUE"),
1.0E-5, 1E6, 6);
if (res && MaxVolume != beforeMaxVolume)
{
MEV->SetMaxElementVolume(MaxVolume);
for (int i=0; i<listSOmesh->length(); i++)
{
mySMESHGUI->GetStudyAPI().ModifiedMesh(listSOmesh[i], false);
}
}
}
// else if (Name.compare("Regular_1D") == 0)
// {}
// else if (Name.compare("MEFISTO_2D") == 0)
// {}
else
{}
}
//=============================================================================
/*! GetHypothesisCreator
*
*/
//=============================================================================
extern "C"
{
SMESHGUI_GenericHypothesisCreator* GetHypothesisCreator
(QString aHypType, QString aServerLibName, SMESHGUI* aSMESHGUI)
{
return new StdMeshersGUI_HypothesisCreator
(aHypType, aServerLibName, aSMESHGUI);
}
}

View File

@ -0,0 +1,289 @@
// SMESH StdMeshersGUI : GUI for StdMeshers plugin
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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.
//
// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : StdMeshersGUI_LocalLengthDlg.cxx
// Moved here from SMESHGUI_LocalLengthDlg.cxx
// Author : Nicolas REJNERI
// Module : SMESH
// $Header$
using namespace std;
#include "StdMeshersGUI_LocalLengthDlg.h"
#include "SMESHGUI.h"
#include "SMESHGUI_SpinBox.h"
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "utilities.h"
#include "SALOMEGUI_QtCatchCorbaException.hxx"
#include "QAD_MessageBox.h"
#include "QAD_WaitCursor.h"
// QT Includes
#include <qgroupbox.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qlayout.h>
#include <qpixmap.h>
//=================================================================================
// class : StdMeshersGUI_LocalLengthDlg()
// purpose : Constructs a StdMeshersGUI_LocalLengthDlg which is a child of 'parent', with the
// name 'name' and widget flags set to 'f'.
// The dialog will by default be modeless, unless you set 'modal' to
// TRUE to construct a modal dialog.
//=================================================================================
StdMeshersGUI_LocalLengthDlg::StdMeshersGUI_LocalLengthDlg (const QString& hypType,
QWidget* parent,
const char* name,
bool modal,
WFlags fl)
: QDialog (parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose),
myHypType(hypType)
{
QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_DLG_LOCAL_LENGTH")));
if ( !name )
setName( "StdMeshersGUI_LocalLengthDlg" );
setCaption( tr( "SMESH_LOCAL_LENGTH_TITLE" ) );
setSizeGripEnabled( TRUE );
QGridLayout* StdMeshersGUI_LocalLengthDlgLayout = new QGridLayout( this );
StdMeshersGUI_LocalLengthDlgLayout->setSpacing( 6 );
StdMeshersGUI_LocalLengthDlgLayout->setMargin( 11 );
/***************************************************************/
iconLabel = new QLabel( this );
iconLabel->setPixmap( image0 );
iconLabel->setScaledContents( false );
iconLabel->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
typeLabel = new QLabel( this );
typeLabel->setText( tr( "SMESH_LOCAL_LENGTH_HYPOTHESIS" ) );
StdMeshersGUI_LocalLengthDlgLayout->addWidget( iconLabel, 0, 0 );
StdMeshersGUI_LocalLengthDlgLayout->addWidget( typeLabel, 0, 1 );
/***************************************************************/
GroupC1 = new QGroupBox( this, "GroupC1" );
GroupC1->setTitle( tr( "SMESH_ARGUMENTS" ) );
GroupC1->setColumnLayout(0, Qt::Vertical );
GroupC1->layout()->setSpacing( 0 );
GroupC1->layout()->setMargin( 0 );
QGridLayout* GroupC1Layout = new QGridLayout( GroupC1->layout() );
GroupC1Layout->setAlignment( Qt::AlignTop );
GroupC1Layout->setSpacing( 6 );
GroupC1Layout->setMargin( 11 );
TextLabel_NameHypothesis = new QLabel( GroupC1, "TextLabel_NameHypothesis" );
TextLabel_NameHypothesis->setText( tr( "SMESH_NAME" ) );
GroupC1Layout->addWidget( TextLabel_NameHypothesis, 0, 0 );
LineEdit_NameHypothesis = new QLineEdit( GroupC1, "LineEdit_NameHypothesis" );
GroupC1Layout->addWidget( LineEdit_NameHypothesis, 0, 1 );
TextLabel_Length = new QLabel(GroupC1 , "TextLabel_Length" );
TextLabel_Length->setText( tr( "SMESH_LENGTH" ) );
GroupC1Layout->addWidget( TextLabel_Length, 1, 0 );
SpinBox_Length = new SMESHGUI_SpinBox( GroupC1, "SpinBox_Length" );
GroupC1Layout->addWidget( SpinBox_Length, 1, 1 );
StdMeshersGUI_LocalLengthDlgLayout->addMultiCellWidget(GroupC1 , 1, 1, 0, 1 );
/***************************************************************/
GroupButtons = new QGroupBox( this, "GroupButtons" );
GroupButtons->setColumnLayout(0, Qt::Vertical );
GroupButtons->layout()->setSpacing( 0 );
GroupButtons->layout()->setMargin( 0 );
QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
GroupButtonsLayout->setAlignment( Qt::AlignTop );
GroupButtonsLayout->setSpacing( 6 );
GroupButtonsLayout->setMargin( 11 );
buttonOk = new QPushButton( GroupButtons, "buttonOk" );
buttonOk->setText( tr( "SMESH_BUT_OK" ) );
buttonOk->setAutoDefault( TRUE );
buttonOk->setDefault( TRUE );
GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
buttonApply = new QPushButton( GroupButtons, "buttonApply" );
buttonApply->setText( tr( "SMESH_BUT_APPLY" ) );
buttonApply->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupButtonsLayout->addItem( spacer, 0, 2 );
buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) );
buttonCancel->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
StdMeshersGUI_LocalLengthDlgLayout->addMultiCellWidget( GroupButtons, 2, 2, 0, 1 );
/***************************************************************/
Init() ;
}
//=================================================================================
// function : ~StdMeshersGUI_LocalLengthDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
StdMeshersGUI_LocalLengthDlg::~StdMeshersGUI_LocalLengthDlg()
{
// no need to delete child widgets, Qt does it all for us
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void StdMeshersGUI_LocalLengthDlg::Init()
{
/* min, max, step and decimals for spin boxes */
SpinBox_Length->RangeStepAndValidator( 0.001, 999.999, 1.0, 3 ) ;
SpinBox_Length->SetValue( 1.0 ) ;
mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
char* sHypType = (char*)myHypType.latin1();
HypothesisData* aHypData = mySMESHGUI->GetHypothesisData(sHypType);
LineEdit_NameHypothesis->setText( aHypData ? aHypData->Label : "" );
mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
/* signals and slots connections */
connect( buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()) );
connect( buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()) ) ;
connect( buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()) );
connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
/* Move widget on the botton right corner of main widget */
int x, y ;
mySMESHGUI->DefineDlgPosition( this, x, y ) ;
this->move( x, y ) ;
this->show() ; /* displays Dialog */
}
//=================================================================================
// function : ClickOnOk()
// purpose :
//=================================================================================
void StdMeshersGUI_LocalLengthDlg::ClickOnOk()
{
if ( this->ClickOnApply() )
this->ClickOnCancel() ;
}
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
bool StdMeshersGUI_LocalLengthDlg::ClickOnApply()
{
QString myHypName = LineEdit_NameHypothesis->text().stripWhiteSpace();
if ( myHypName.isEmpty() ) {
QAD_MessageBox::warn1( this, tr( "SMESH_WRN_WARNING" ), tr( "SMESH_WRN_EMPTY_NAME" ), tr( "SMESH_BUT_OK" ) );
return false;
}
double myLength = SpinBox_Length->GetValue();
QAD_WaitCursor wc;
try {
SMESH::SMESH_Hypothesis_var Hyp = SMESH::SMESH_Hypothesis::_narrow
(mySMESHGUI->CreateHypothesis(myHypType,
myHypName,
false)); // isAlgorithm
StdMeshers::StdMeshers_LocalLength_var LL =
StdMeshers::StdMeshers_LocalLength::_narrow(Hyp);
if (!LL->_is_nil())
LL->SetLength(myLength);
}
catch (const SALOME::SALOME_Exception& S_ex) {
wc.stop();
QtCatchCorbaException(S_ex);
return false;
}
return true;
}
//=================================================================================
// function : ClickOnCancel()
// purpose :
//=================================================================================
void StdMeshersGUI_LocalLengthDlg::ClickOnCancel()
{
close();
}
//=================================================================================
// function : DeactivateActiveDialog()
// purpose :
//=================================================================================
void StdMeshersGUI_LocalLengthDlg::DeactivateActiveDialog()
{
iconLabel->setEnabled(false) ;
typeLabel->setEnabled(false) ;
GroupC1->setEnabled(false) ;
GroupButtons->setEnabled(false) ;
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void StdMeshersGUI_LocalLengthDlg::ActivateThisDialog()
{
mySMESHGUI->EmitSignalDeactivateDialog() ;
iconLabel->setEnabled(true) ;
typeLabel->setEnabled(true) ;
GroupC1->setEnabled(true) ;
GroupButtons->setEnabled(true) ;
}
//=================================================================================
// function : enterEvent()
// purpose :
//=================================================================================
void StdMeshersGUI_LocalLengthDlg::enterEvent(QEvent* e)
{
ActivateThisDialog() ;
}
//=================================================================================
// function : closeEvent()
// purpose :
//=================================================================================
void StdMeshersGUI_LocalLengthDlg::closeEvent( QCloseEvent* e )
{
mySMESHGUI->ResetState();
QDialog::closeEvent( e );
}

Some files were not shown because too many files have changed in this diff Show More