[cgma-dev] r2504 - cgm/trunk/geom/OCC
janehu at mcs.anl.gov
janehu at mcs.anl.gov
Mon Jan 5 14:16:07 CST 2009
Author: janehu
Date: 2009-01-05 14:16:07 -0600 (Mon, 05 Jan 2009)
New Revision: 2504
Modified:
cgm/trunk/geom/OCC/OCCModifyEngine.cpp
cgm/trunk/geom/OCC/OCCSurface.cpp
Log:
Added get_mid_plane function and passed tests.
Modified: cgm/trunk/geom/OCC/OCCModifyEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2009-01-02 18:29:35 UTC (rev 2503)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2009-01-05 20:16:07 UTC (rev 2504)
@@ -3458,8 +3458,18 @@
GProp_GProps myProps;
BRepGProp::VolumeProperties(*from_shape, myProps);
double orig_mass = myProps.Mass();
- BRepGProp::VolumeProperties(cut_shape, myProps);
- double after_mass = myProps.Mass();
+ TopTools_IndexedMapOfShape M;
+ TopExp::MapShapes(cut_shape, TopAbs_SOLID, M);
+ double after_mass;
+ CubitBoolean no_volume = CUBIT_FALSE;
+ if(M.Extent() > 0)
+ {
+ BRepGProp::VolumeProperties(cut_shape, myProps);
+ after_mass = myProps.Mass();
+ }
+ else
+ no_volume = CUBIT_TRUE;
+
if(fabs(-after_mass + orig_mass) <= tol)
{
has_changed= CUBIT_FALSE; //common is itself
@@ -3467,7 +3477,7 @@
}
//got cut. Update the entities
- if(after_mass < tol) //no common section
+ if(after_mass < tol && !no_volume) //no common section
cut_shape.Nullify();
has_changed = CUBIT_TRUE;
TopExp_Explorer Ex;
@@ -5300,17 +5310,50 @@
// Function : get_mid_plane
// Member Type: PUBLIC
// Description:
-// Author : John Fowler
-// Date : 10/02
+// Author : Jane Hu
+// Date : 01/09
//===============================================================================
-CubitStatus OCCModifyEngine::get_mid_plane( const CubitVector & /*point_1*/,
- const CubitVector & /*point_2*/,
- const CubitVector & /*point_3*/,
- BodySM * /*body_to_trim_to*/,
- BodySM *& /*midplane_body*/ ) const
+CubitStatus OCCModifyEngine::get_mid_plane( const CubitVector & point_1,
+ const CubitVector & point_2,
+ const CubitVector & point_3,
+ BodySM * body_to_trim_to,
+ BodySM *& midplane_body ) const
{
- PRINT_ERROR("Option not supported for mesh based geometry.\n");
- return CUBIT_FAILURE;
+ //Calculate normal of the mid plane
+ CubitVector v1, v2, normal;
+ v1 = point_2 - point_1;
+ v2 = point_3 - point_1;
+ normal = ~(v1 * v2);
+ if(normal.length() != 1)
+ {
+ PRINT_ERROR("The three points are co-linear, and can't be used as a cutting plane.\n");
+ return CUBIT_FAILURE;
+ }
+
+ gp_Pnt pt = gp_Pnt( point_1.x(), point_1.y(), point_1.z());
+ gp_Dir normal_dir(normal.x(), normal.y(), normal.z());
+ gp_Pln plane(pt, normal_dir);
+
+ TopoDS_Face face = BRepBuilderAPI_MakeFace(plane);
+ Surface *surf = OCCQueryEngine::instance()->populate_topology_bridge(face,
+ CUBIT_TRUE);
+ if(!surf)
+ {
+ PRINT_ERROR("Can't create cutting plane.\n");
+ return CUBIT_FAILURE;
+ }
+
+ BodySM* tool = CAST_TO(surf, OCCSurface)->my_body();
+ DLIList<BodySM*> from_bodies, new_bodies;
+ from_bodies.append(body_to_trim_to);
+
+ CubitStatus stat = intersect(tool, from_bodies, new_bodies,
+ CUBIT_TRUE);
+ OCCQueryEngine::instance()->delete_solid_model_entities(tool);
+
+ if(stat)
+ midplane_body = new_bodies.get();
+ return stat;
}
CubitStatus OCCModifyEngine::get_spheric_mid_surface( Surface* surface_ptr1,
Modified: cgm/trunk/geom/OCC/OCCSurface.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCSurface.cpp 2009-01-02 18:29:35 UTC (rev 2503)
+++ cgm/trunk/geom/OCC/OCCSurface.cpp 2009-01-05 20:16:07 UTC (rev 2504)
@@ -971,7 +971,24 @@
OCCQueryEngine::instance()->update_OCC_map(wire, shape);
}
if (!old_surface.IsSame(new_surface))
- OCCQueryEngine::instance()->update_OCC_map(old_surface, new_surface);
+ {
+ TopAbs_ShapeEnum shapetype;
+ if(!new_surface.IsNull())
+ shapetype = new_surface.TShape()->ShapeType();
+ if(shapetype == TopAbs_FACE || new_surface.IsNull())
+ OCCQueryEngine::instance()->update_OCC_map(old_surface, new_surface);
+ else
+ {
+ TopTools_IndexedMapOfShape M;
+ TopExp::MapShapes(new_surface, TopAbs_FACE, M);
+ TopoDS_Shape new_shape;
+ if(M.Extent() > 0)
+ new_shape = M(1);
+ else
+ new_shape = new_surface;
+ OCCQueryEngine::instance()->update_OCC_map(old_surface, new_shape);
+ }
+ }
return CUBIT_SUCCESS;
}
More information about the cgma-dev
mailing list