[cgma-dev] r1322 - in cgm/trunk: . geom geom/OCC util
janehu at mcs.anl.gov
janehu at mcs.anl.gov
Tue Oct 23 11:56:56 CDT 2007
Author: janehu
Date: 2007-10-23 11:56:56 -0500 (Tue, 23 Oct 2007)
New Revision: 1322
Modified:
cgm/trunk/configure.in
cgm/trunk/geom/Makefile.am
cgm/trunk/geom/OCC/OCCBody.cpp
cgm/trunk/geom/OCC/OCCQueryEngine.cpp
cgm/trunk/util/GeometryDefines.h
Log:
Check in configure.in and Makefile.am as well as adding reflect, rotate, scale, translate for body and other entities in OCC query funtions.
Modified: cgm/trunk/configure.in
===================================================================
--- cgm/trunk/configure.in 2007-10-22 16:59:37 UTC (rev 1321)
+++ cgm/trunk/configure.in 2007-10-23 16:56:56 UTC (rev 1322)
@@ -240,6 +240,58 @@
################################################################################
+# OCC Options
+################################################################################
+# Add --with-occ option to configure script
+AC_ARG_WITH( occ,
+ [AC_HELP_STRING([--with-occ=<dir>],[OpenCascade shared library directory])],
+ [occ_DIR="$withval"],
+ [occ_DIR=no] )
+
+# if user specified option (other than --without-occ)
+if test "x$occ_DIR" != "xno"; then
+
+ # Set OCC_INC_FLAG and OCC_LIB_FLAG based on --with-occ option
+ if test "x$occ_DIR" = "x"; then
+ OCC_INC_FLAG=
+ OCC_LIB_FLAG=
+ else
+ uname=`uname`
+ OCC_INC_FLAG="-I${occ_DIR}/ros/inc"
+# -I/usr/include/c++/4.2 -I/usr/include/c++/4.2/tr1"
+ OCC_LIB_FLAG="-L${occ_DIR}/ros/${uname}/lib"
+ fi
+
+ # Check of OCC is present and working
+
+ # Save old value of these variables and update working ones
+ old_CPPFLAGS="$CPPFLAGS"
+ old_LDFLAGS="$LDFLAGS"
+ CPPFLAGS="$CPPFLAGS ${OCC_INC_FLAG}"
+ LDFLAGS="$LDFLAGS ${OCC_LIB_FLAG}"
+
+ # Check if OCC has Stadard_Version.hxx
+ AC_CHECK_HEADER( [Standard_Version.hxx], [],
+ [AC_MSG_ERROR([OpenCascade config error:Standard_Version.hxx not found])] )
+
+ # Check if libTKernel.so contains function 'create_mailbox'
+ AC_CHECK_LIB( [TKernel], [create_mailbox],,
+ [AC_MSG_ERROR([OpenCascade config error: libTKernel not found ])])
+
+ # Restore original values of variables
+ CPPFLAGS="$old_CPPFLAGS"
+ LDFLAGS="$old_LDFLAGS"
+fi
+
+# Export these variables as variables in Makefiles
+AC_SUBST(OCC_INC_FLAG)
+AC_SUBST(OCC_LIB_FLAG)
+
+# Allow "if WITH_OCC" in Makefile.am
+AM_CONDITIONAL( WITH_OCC, [test "x$occ_DIR" != "xno"] )
+
+
+################################################################################
# Output Files
################################################################################
AC_MSG_RESULT([CXXFLAGS = $CXXFLAGS])
@@ -254,6 +306,7 @@
geom/Cholla/Makefile
geom/facet/Makefile
geom/facetbool/Makefile
+ geom/OCC/Makefile
geom/parallel/Makefile
geom/virtual/Makefile
init/Makefile
Modified: cgm/trunk/geom/Makefile.am
===================================================================
--- cgm/trunk/geom/Makefile.am 2007-10-22 16:59:37 UTC (rev 1321)
+++ cgm/trunk/geom/Makefile.am 2007-10-23 16:56:56 UTC (rev 1322)
@@ -11,6 +11,9 @@
if build_parallel
SUBDIRS += parallel
endif
+if WITH_OCC
+ SUBDIRS += OCC
+endif
# Override default defines with the ones we want from the configure script
DEFS = $(TEMPLATE_DEFS_INCLUDED) $(LITTLE_ENDIAN)
Modified: cgm/trunk/geom/OCC/OCCBody.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCBody.cpp 2007-10-22 16:59:37 UTC (rev 1321)
+++ cgm/trunk/geom/OCC/OCCBody.cpp 2007-10-23 16:56:56 UTC (rev 1322)
@@ -158,19 +158,17 @@
// Function: move
// Description: translate the body and its child entities
//
-// Author: sjowen
+// Author: Jane Hu
//----------------------------------------------------------------
CubitStatus OCCBody::move(double dx, double dy, double dz)
{
- CubitTransformMatrix tfmat;
- tfmat.translate( dx, dy, dz );
+ gp_Vec aVec(dx, dy, dz);
+ gp_Trsf aTrsf;
+ aTrsf.SetTranslation(aVec);
- CubitStatus stat = transform( tfmat, CUBIT_FALSE );
-
- if (stat == CUBIT_SUCCESS)
- myTransforms.translate( dx, dy, dz );
-
- return stat;
+ BRepBuilderAPI_Transform aBRepTrsf(*myTopoDSShape, aTrsf);
+ update_bounding_box();
+ return CUBIT_SUCCESS;
}
@@ -178,22 +176,22 @@
// Function: rotate
// Description: rotate the body and its child entities
//
-// Author: sjowen
+// Author: Jane Hu
//----------------------------------------------------------------
CubitStatus OCCBody::rotate( double x, double y, double z,
- double angle_in_degrees )
+ double angle )//in radians
{
+ gp_Pnt aOrigin(0,0,0);
+ gp_Dir aDir(x, y, z);
+ gp_Ax1 anAxis(aOrigin, aDir);
- CubitTransformMatrix rotmat;
- CubitVector axis( x, y, z );
- rotmat.rotate( angle_in_degrees, axis );
+ //a is angular value of rotation in radians
+ gp_Trsf aTrsf;
+ aTrsf.SetRotation(anAxis, angle);
- CubitStatus stat = transform( rotmat, CUBIT_TRUE );
-
- if (stat == CUBIT_SUCCESS)
- myTransforms.rotate( angle_in_degrees, axis );
-
- return stat;
+ BRepBuilderAPI_Transform aBRepTrsf(*myTopoDSShape, aTrsf);
+ update_bounding_box();
+ return CUBIT_SUCCESS;
}
//----------------------------------------------------------------
@@ -201,51 +199,30 @@
// Description: scale the body and its child entities
// use a constant scale factor
//
-// Author: sjowen
+// Author: Jane Hu
//----------------------------------------------------------------
CubitStatus OCCBody::scale(double scale_factor )
{
- return scale(scale_factor,scale_factor,scale_factor);
+ gp_Trsf aTrsf;
+ aTrsf.SetScaleFactor(scale_factor);
+
+ BRepBuilderAPI_Transform aBRepTrsf(*myTopoDSShape, aTrsf);
+ update_bounding_box();
+ return CUBIT_SUCCESS;
}
//----------------------------------------------------------------
// Function: scale
// Description: scale the body and its child entities
//
-// Author: sjowen
+// Author:
//----------------------------------------------------------------
CubitStatus OCCBody::scale(double scale_factor_x,
double scale_factor_y,
double scale_factor_z )
{
- CubitTransformMatrix scalemat;
- scalemat.scale_about_origin( scale_factor_x,
- scale_factor_y,
- scale_factor_z );
-
- CubitStatus stat = transform( scalemat, CUBIT_FALSE );
-
- if (stat == CUBIT_SUCCESS)
- myTransforms.scale_about_origin( scale_factor_x,
- scale_factor_y,
- scale_factor_z );
-
- // scale the facetcurve
-
- DLIList<OCCCurve *> curve_list;
- //get_curves(curve_list);
- Curve *curv_ptr;
- for (int ii=0; ii<curve_list.size(); ii++)
- {
- curv_ptr = curve_list.get_and_step();
- OCCCurve *fcurve = CAST_TO( curv_ptr, OCCCurve );
- if (fcurve)
- {
- fcurve->reset_length();
- }
- }
-
- return stat;
+ PRINT_ERROR("non-uniform scaling is not performed on OCC bodies");
+ return CUBIT_FAILURE;
}
//----------------------------------------------------------------
@@ -276,7 +253,7 @@
// Function: reflect
// Description: reflect the body about a exis
//
-// Author: sjowen
+// Author: Jane Hu
//----------------------------------------------------------------
CubitStatus OCCBody::reflect( double reflect_axis_x,
double reflect_axis_y,
Modified: cgm/trunk/geom/OCC/OCCQueryEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCQueryEngine.cpp 2007-10-22 16:59:37 UTC (rev 1321)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.cpp 2007-10-23 16:56:56 UTC (rev 1322)
@@ -16,8 +16,10 @@
#include "config.h"
#include "BRep_Tool.hxx"
#include "gp_Pnt.hxx"
+#include "gp_Ax1.hxx"
#include "Geom_Surface.hxx"
#include "Geom_Curve.hxx"
+#include "BRepBuilderAPI_Transform.hxx"
#include "OCCQueryEngine.hpp"
#include "OCCModifyEngine.hpp"
#include "TopologyEntity.hpp"
@@ -196,7 +198,7 @@
// Date : 9/7/01
//================================================================================
CubitStatus OCCQueryEngine::reflect( BodySM *bodysm,
- const CubitVector& axis)
+ const CubitVector& axis)
{
OCCBody *body = CAST_TO(bodysm, OCCBody);
if (!body)
@@ -1829,7 +1831,7 @@
return status;
}
-const char* fqe_xform_err = "Transform not implemented for facet geometry.\n";
+const char* fqe_xform_err = "Transform not implemented for OCC geometry.\n";
CubitStatus OCCQueryEngine::restore_transform( BodySM* body )
{
OCCBody* facetbod = dynamic_cast<OCCBody*>(body);
@@ -1837,8 +1839,8 @@
}
CubitStatus OCCQueryEngine::translate( BodySM* body, const CubitVector& d )
{
- OCCBody* facetbod = dynamic_cast<OCCBody*>(body);
- return facetbod ? facetbod->move( d.x(), d.y(), d.z() ) : CUBIT_FAILURE;
+ OCCBody* theBody = dynamic_cast<OCCBody*>(body);
+ return theBody ? theBody->move( d.x(), d.y(), d.z() ) : CUBIT_FAILURE;
}
CubitStatus OCCQueryEngine::rotate( BodySM* body, const CubitVector& v, double a )
{
@@ -1856,38 +1858,108 @@
return facetbod ? facetbod->scale( f.x(), f.y(), f.z() ) : CUBIT_FAILURE;
}
-CubitStatus OCCQueryEngine::translate( GeometryEntity* , const CubitVector& )
+//-------------------------------------------------------------------------
+// Purpose : Transform a Solid, Surface, Curve, or Vertex
+//
+// Special Notes :
+//
+// Creator : Jane Hu
+//
+// Creation Date : 10/23/07
+//-------------------------------------------------------------------------
+CubitStatus OCCQueryEngine::translate( GeometryEntity* entity,
+ const CubitVector& v )
{
- PRINT_ERROR(fqe_xform_err);
- return CUBIT_FAILURE;
+ TopoDS_Shape * shape;
+ if ((shape = get_TopoDS_Shape_of_entity(entity)) == NULL)
+ {
+ PRINT_ERROR( "problem occured getting OCC entity.\n"
+ " Aborting.\n" );
+ return CUBIT_FAILURE;
+ }
+
+ gp_Vec aVec(v.x(), v.y(),v.z());
+ gp_Trsf aTrsf;
+ aTrsf.SetTranslation(aVec);
+
+ BRepBuilderAPI_Transform aBRepTrsf(*shape, aTrsf);
+ return CUBIT_SUCCESS;
}
-CubitStatus OCCQueryEngine::rotate( GeometryEntity* , const CubitVector& , double )
+
+//a is angular value of rotation in radians
+CubitStatus OCCQueryEngine::rotate( GeometryEntity* entity,
+ const CubitVector& v, double a )
{
- PRINT_ERROR(fqe_xform_err);
- return CUBIT_FAILURE;
+ TopoDS_Shape * shape;
+ if ((shape = get_TopoDS_Shape_of_entity(entity)) == NULL)
+ {
+ PRINT_ERROR( "problem occured getting OCC entity.\n"
+ " Aborting.\n" );
+ return CUBIT_FAILURE;
+ }
+
+ gp_Pnt aOrigin(0,0,0);
+ gp_Dir aDir(v.x(), v.y(), v.z());
+ gp_Ax1 anAxis(aOrigin, aDir);
+
+ //a is angular value of rotation in radians
+ gp_Trsf aTrsf;
+ aTrsf.SetRotation(anAxis, a);
+
+ BRepBuilderAPI_Transform aBRepTrsf(*shape, aTrsf);
+ return CUBIT_SUCCESS;
}
-CubitStatus OCCQueryEngine::scale( GeometryEntity* , double )
+
+CubitStatus OCCQueryEngine::scale( GeometryEntity* entity, double f )
{
- PRINT_ERROR(fqe_xform_err);
- return CUBIT_FAILURE;
+ TopoDS_Shape * shape;
+ if ((shape = get_TopoDS_Shape_of_entity(entity)) == NULL)
+ {
+ PRINT_ERROR( "problem occured getting OCC entity.\n"
+ " Aborting.\n" );
+ return CUBIT_FAILURE;
+ }
+
+ gp_Trsf aTrsf;
+ aTrsf.SetScaleFactor(f);
+
+ BRepBuilderAPI_Transform aBRepTrsf(*shape, aTrsf);
+ return CUBIT_SUCCESS;
}
+
CubitStatus OCCQueryEngine::scale( GeometryEntity* , const CubitVector& )
{
- PRINT_ERROR(fqe_xform_err);
+ PRINT_ERROR("non-uniform scaling is not performed on OCC bodies");
return CUBIT_FAILURE;
}
-CubitStatus OCCQueryEngine::reflect( GeometryEntity* , const CubitVector& )
+CubitStatus OCCQueryEngine::reflect( GeometryEntity* entity,
+ const CubitVector& v)
{
- PRINT_ERROR(fqe_xform_err);
- return CUBIT_FAILURE;
+ TopoDS_Shape * shape;
+ if ((shape = get_TopoDS_Shape_of_entity(entity)) == NULL)
+ {
+ PRINT_ERROR( "problem occured getting OCC entity.\n"
+ " Aborting.\n" );
+ return CUBIT_FAILURE;
+ }
+
+ gp_Pnt aOrigin(0,0,0);
+ gp_Dir aDir(v.x(), v.y(), v.z());
+ gp_Ax1 anAxis(aOrigin, aDir);
+
+ gp_Trsf aTrsf;
+ aTrsf.SetMirror(anAxis);
+
+ BRepBuilderAPI_Transform aBRepTrsf(*shape, aTrsf);
+ return CUBIT_SUCCESS;
}
//===============================================================================
// Function : bodies_overlap
// Member Type: PUBLIC
-// Description: determine if facet-based bodies overlap
-// Author : John Fowler
-// Date : 10/02
+// Description: determine if OCC-based bodies overlap
+// Author :
+// Date : 10/07
//===============================================================================
CubitBoolean OCCQueryEngine::bodies_overlap (BodySM * body_ptr_1,
BodySM * body_ptr_2 ) const
Modified: cgm/trunk/util/GeometryDefines.h
===================================================================
--- cgm/trunk/util/GeometryDefines.h 2007-10-22 16:59:37 UTC (rev 1321)
+++ cgm/trunk/util/GeometryDefines.h 2007-10-23 16:56:56 UTC (rev 1322)
@@ -34,6 +34,7 @@
enum SolidModelerType
{
NOT_A_SOLID_MODELER,
+ OCC,
ACIS,
PROE_GEOM, /* Normal Pro/E model */
PROE_FEM_MESH_SOLID, /* Pro/Mesh models... */
@@ -67,6 +68,8 @@
SPLINE_CURVE_TYPE,
STRAIGHT_CURVE_TYPE,
POINT_CURVE_TYPE,
+ BEZIER_CURVE_TYPE, //OCC curve types
+ HYPERBOLA_CURVE_TYPE,
UNDEFINED_CURVE_TYPE,
/* Surface types */
More information about the cgma-dev
mailing list