[cgma-dev] r2059 - in cgm/trunk: geom/OCC test
janehu at mcs.anl.gov
janehu at mcs.anl.gov
Wed Sep 10 13:27:43 CDT 2008
Author: janehu
Date: 2008-09-10 13:27:43 -0500 (Wed, 10 Sep 2008)
New Revision: 2059
Modified:
cgm/trunk/geom/OCC/OCCBody.cpp
cgm/trunk/geom/OCC/OCCCurve.cpp
cgm/trunk/geom/OCC/OCCLoop.cpp
cgm/trunk/geom/OCC/OCCLump.cpp
cgm/trunk/geom/OCC/OCCModifyEngine.cpp
cgm/trunk/geom/OCC/OCCPoint.cpp
cgm/trunk/geom/OCC/OCCQueryEngine.cpp
cgm/trunk/geom/OCC/OCCShell.cpp
cgm/trunk/geom/OCC/OCCSurface.cpp
cgm/trunk/geom/OCC/OCCSurface.hpp
cgm/trunk/test/modify.cpp
Log:
Added flip_normals function in OCCModifyEngine, and passed test cases.
Modified: cgm/trunk/geom/OCC/OCCBody.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCBody.cpp 2008-09-10 01:13:26 UTC (rev 2058)
+++ cgm/trunk/geom/OCC/OCCBody.cpp 2008-09-10 18:27:43 UTC (rev 2059)
@@ -86,9 +86,10 @@
void OCCBody::set_TopoDS_Shape( TopoDS_CompSolid theshape)
{
+ TopoDS_CompSolid * the_comp = new TopoDS_CompSolid(theshape);
if(myTopoDSShape)
delete myTopoDSShape;
- myTopoDSShape = new TopoDS_CompSolid(theshape);
+ myTopoDSShape = the_comp;
}
OCCBody::OCCBody(DLIList<Lump*>& my_lumps)
Modified: cgm/trunk/geom/OCC/OCCCurve.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCCurve.cpp 2008-09-10 01:13:26 UTC (rev 2058)
+++ cgm/trunk/geom/OCC/OCCCurve.cpp 2008-09-10 18:27:43 UTC (rev 2059)
@@ -117,9 +117,10 @@
void OCCCurve::set_TopoDS_Edge(TopoDS_Edge edge)
{
+ TopoDS_Edge* the_edge = new TopoDS_Edge(edge);
if(myTopoDSEdge)
delete myTopoDSEdge;
- myTopoDSEdge = new TopoDS_Edge(edge);
+ myTopoDSEdge = the_edge;
}
//-------------------------------------------------------------------------
Modified: cgm/trunk/geom/OCC/OCCLoop.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCLoop.cpp 2008-09-10 01:13:26 UTC (rev 2058)
+++ cgm/trunk/geom/OCC/OCCLoop.cpp 2008-09-10 18:27:43 UTC (rev 2059)
@@ -68,9 +68,10 @@
void OCCLoop::set_TopoDS_Wire(TopoDS_Wire loop)
{
+ TopoDS_Wire* the_wire = new TopoDS_Wire(loop);
if(myTopoDSWire)
delete myTopoDSWire;
- myTopoDSWire = new TopoDS_Wire(loop);
+ myTopoDSWire = the_wire;
}
//-------------------------------------------------------------------------
// Purpose : Tear down topology
Modified: cgm/trunk/geom/OCC/OCCLump.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCLump.cpp 2008-09-10 01:13:26 UTC (rev 2058)
+++ cgm/trunk/geom/OCC/OCCLump.cpp 2008-09-10 18:27:43 UTC (rev 2059)
@@ -83,10 +83,11 @@
void OCCLump::set_TopoDS_Solid(TopoDS_Solid solid)
{
+ TopoDS_Solid* the_solid = new TopoDS_Solid(solid);
if(myTopoDSSolid)
delete myTopoDSSolid ;
- myTopoDSSolid = new TopoDS_Solid(solid);
+ myTopoDSSolid = the_solid;
}
//-------------------------------------------------------------------------
// Purpose : Find centroid
Modified: cgm/trunk/geom/OCC/OCCModifyEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-09-10 01:13:26 UTC (rev 2058)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-09-10 18:27:43 UTC (rev 2059)
@@ -28,6 +28,7 @@
#include "BRepBuilderAPI_MakeSolid.hxx"
#include "BRepBuilderAPI_MakeWire.hxx"
#include "TopoDS_Shape.hxx"
+#include "TopAbs_Orientation.hxx"
#include "TColgp_Array1OfPnt.hxx"
#include "GC_MakeArcOfCircle.hxx"
#include "GC_MakeArcOfHyperbola.hxx"
@@ -79,6 +80,7 @@
#include "TopExp.hxx"
#include "OCCModifyEngine.hpp"
#include "OCCQueryEngine.hpp"
+#include "OCCCoFace.hpp"
#include "CubitMessage.hpp"
#include "CubitDefines.h"
#include "TopTools_DataMapOfShapeInteger.hxx"
@@ -3318,7 +3320,7 @@
for (int i = 0; i < shape_list.size(); i++)
{
TopoDS_Shape* from_shape = shape_list.get_and_step();
- BodySM* from_body = from_bodies.get_and_step();
+ //BodySM* from_body = from_bodies.get_and_step();
BRepAlgoAPI_Common intersector(*from_shape, *tool_shape);
TopoDS_Shape common_shape = intersector.Shape();
check_operation(common_shape, from_shape, is_volume[i], has_changed,
@@ -3516,7 +3518,7 @@
//find a non-sheet body to be the first shape
TopoDS_Shape* first_shape;
CubitBoolean first_is_volume;
- if(first_is_volume = is_volume.move_to(CUBIT_TRUE))
+ if((first_is_volume = is_volume.move_to(CUBIT_TRUE)))
{
int index = is_volume.get_index();
first_shape = shape_list[index];
@@ -3534,8 +3536,6 @@
}
int size = shape_list.size();
- OCCBody* deleted_body = NULL;
- CubitBoolean restore_first_shape = CUBIT_FALSE;
for(int i = 0; i < size; i++)
{
TopoDS_Shape* second_shape = shape_list.get_and_step();
@@ -3681,8 +3681,55 @@
//===============================================================================
CubitStatus OCCModifyEngine :: flip_normals( DLIList<Surface*>& face_list ) const
{
- PRINT_ERROR("Option not supported for OCC based geometry.\n");
- return CUBIT_FAILURE;
+ while (face_list.size())
+ {
+ OCCSurface* occ_surface = CAST_TO(face_list.pop(), OCCSurface);
+ OCCShell* occ_shell = occ_surface->my_shell();
+ DLIList<OCCSurface*> surfaces;
+ surfaces.append(occ_surface);
+ if(occ_shell) //find all surfaces in face_list that belong to this shell
+ {
+ while ( face_list.size())
+ {
+ occ_surface = CAST_TO(face_list.get(), OCCSurface);
+ if(occ_shell == occ_surface->my_shell())
+ surfaces.append(CAST_TO(face_list.remove(),OCCSurface));
+ }
+
+ if (!occ_shell->is_sheet())
+ {
+ DLIList<OCCCoFace*> cofaces;
+ cofaces = occ_shell->cofaces();
+ for(int i = 0; i < cofaces.size(); i++)
+ {
+ OCCCoFace* coface =cofaces.get_and_step();
+ occ_surface = coface->surface();
+ if(surfaces.is_in_list(occ_surface))
+ {
+ TopoDS_Face* topoface = occ_surface->get_TopoDS_Face();
+ TopAbs_Orientation ori = topoface->Orientation();
+ topoface->Orientation(ori == TopAbs_FORWARD ? TopAbs_REVERSED :
+ TopAbs_FORWARD);
+ occ_surface->set_TopoDS_Face(*topoface);
+ coface->set_sense(coface->sense() == CUBIT_FORWARD ?
+ CUBIT_REVERSED : CUBIT_FORWARD);
+ }
+ }
+ }
+ else //sheet body
+ {
+ TopoDS_Face* topoface = occ_surface->get_TopoDS_Face();
+ TopAbs_Orientation ori = topoface->Orientation();
+ topoface->Orientation(ori == TopAbs_FORWARD ? TopAbs_REVERSED :
+ TopAbs_FORWARD);
+ occ_surface->set_TopoDS_Face(*topoface);
+ }
+ PRINT_INFO( "Modified volume\n" );
+ }
+ else
+ PRINT_WARNING( "Volume was not modified\n" );
+ }
+ return CUBIT_SUCCESS;
}
Modified: cgm/trunk/geom/OCC/OCCPoint.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCPoint.cpp 2008-09-10 01:13:26 UTC (rev 2058)
+++ cgm/trunk/geom/OCC/OCCPoint.cpp 2008-09-10 18:27:43 UTC (rev 2059)
@@ -87,9 +87,10 @@
void OCCPoint::set_TopoDS_Vertex(TopoDS_Vertex vertex)
{
+ TopoDS_Vertex* the_vertex = new TopoDS_Vertex(vertex);
if(myTopoDSVertex)
delete myTopoDSVertex;
- myTopoDSVertex = new TopoDS_Vertex(vertex);
+ myTopoDSVertex = the_vertex;
}
//-------------------------------------------------------------------------
// Purpose : The purpose of this function is to append a
Modified: cgm/trunk/geom/OCC/OCCQueryEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCQueryEngine.cpp 2008-09-10 01:13:26 UTC (rev 2058)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.cpp 2008-09-10 18:27:43 UTC (rev 2059)
@@ -1365,7 +1365,8 @@
{
int k = OCCMap->Find(aShape);
surface = (OCCSurface*)(OccToCGM->find(k))->second;
- surface->set_TopoDS_Face(aShape);
+ TopoDS_Face aFace(aShape);
+ surface->set_TopoDS_Face(aFace);
}
TopExp_Explorer Ex;
Modified: cgm/trunk/geom/OCC/OCCShell.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCShell.cpp 2008-09-10 01:13:26 UTC (rev 2058)
+++ cgm/trunk/geom/OCC/OCCShell.cpp 2008-09-10 18:27:43 UTC (rev 2059)
@@ -83,10 +83,11 @@
void OCCShell::set_TopoDS_Shell(TopoDS_Shell shell)
{
+ TopoDS_Shell* the_shell = new TopoDS_Shell(shell);
if (myTopoDSShell)
delete myTopoDSShell;
- myTopoDSShell = new TopoDS_Shell(shell);
+ myTopoDSShell = the_shell;
}
//-------------------------------------------------------------------------
Modified: cgm/trunk/geom/OCC/OCCSurface.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCSurface.cpp 2008-09-10 01:13:26 UTC (rev 2058)
+++ cgm/trunk/geom/OCC/OCCSurface.cpp 2008-09-10 18:27:43 UTC (rev 2059)
@@ -98,11 +98,12 @@
delete myTopoDSFace;
}
-void OCCSurface::set_TopoDS_Face(TopoDS_Face face)
+void OCCSurface::set_TopoDS_Face(TopoDS_Face& face)
{
+ TopoDS_Face* face_ptr = new TopoDS_Face(face);
if(myTopoDSFace)
delete myTopoDSFace;
- myTopoDSFace = new TopoDS_Face(face);
+ myTopoDSFace = face_ptr ;
}
@@ -280,11 +281,15 @@
if (closest_location != NULL)
*closest_location = CubitVector(newP.X(), newP.Y(), newP.Z());
if (unit_normal_ptr != NULL) {
- gp_Dir normal;
- if (SLP.IsNormalDefined()) {
- normal = SLP.Normal();
- *unit_normal_ptr = CubitVector(normal.X(), normal.Y(), normal.Z());
- }
+ gp_Dir normal;
+ //normal of a RefFace point to outside of the material
+ if (SLP.IsNormalDefined()) {
+ normal = SLP.Normal();
+ CubitSense sense = get_geometry_sense();
+ if(sense == CUBIT_REVERSED)
+ normal.Reverse() ;
+ *unit_normal_ptr = CubitVector(normal.X(), normal.Y(), normal.Z());
+ }
}
gp_Dir MaxD, MinD;
@@ -791,7 +796,7 @@
//update all attributes first.
TopTools_ListIteratorOfListOfShape it;
it.Initialize(shapes);
- for(it; it.More(); it.Next())
+ for(; it.More(); it.Next())
{
shape = it.Value();
OCCQueryEngine::instance()->copy_attributes(*get_TopoDS_Face(), shape);
@@ -890,7 +895,7 @@
//update all attributes first.
TopTools_ListIteratorOfListOfShape it;
it.Initialize(shapes);
- for(it; it.More(); it.Next())
+ for(; it.More(); it.Next())
{
shape_edge = it.Value();
OCCQueryEngine::instance()->copy_attributes(edge, shape_edge);
@@ -917,7 +922,7 @@
//update all attributes first.
TopTools_ListIteratorOfListOfShape it;
it.Initialize(shapes);
- for(it; it.More(); it.Next())
+ for(; it.More(); it.Next())
{
shape_vertex = it.Value();
OCCQueryEngine::instance()->copy_attributes(vertex, shape_vertex);
Modified: cgm/trunk/geom/OCC/OCCSurface.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCSurface.hpp 2008-09-10 01:13:26 UTC (rev 2058)
+++ cgm/trunk/geom/OCC/OCCSurface.hpp 2008-09-10 18:27:43 UTC (rev 2059)
@@ -308,7 +308,7 @@
//- values.
TopoDS_Face *get_TopoDS_Face(){return myTopoDSFace;}
- void set_TopoDS_Face(TopoDS_Face face);
+ void set_TopoDS_Face(TopoDS_Face& face);
void get_loops(DLIList<OCCLoop*>&);
Modified: cgm/trunk/test/modify.cpp
===================================================================
--- cgm/trunk/test/modify.cpp 2008-09-10 01:13:26 UTC (rev 2058)
+++ cgm/trunk/test/modify.cpp 2008-09-10 18:27:43 UTC (rev 2059)
@@ -133,6 +133,7 @@
body->ref_faces(ref_faces);
DLIList<RefFace*> faces_to_stitch;
+ RefFace* test_face = NULL;
for(int i = 0 ; i < ref_faces.size(); i++)
{
RefFace* refface = gmti->make_RefFace(ref_faces.get_and_step());
@@ -140,11 +141,21 @@
faces_to_stitch.append(refface);
}
+ DLIList<Surface*> surface_list;
+ test_face = gmti->make_RefFace(ref_faces.get());
+ surface_list.append(test_face->get_surface_ptr());
+ CubitVector v_test(0,5,5);
+ CubitVector normal;
+ normal = test_face->normal_at(v_test); //(-1,0,0)
+ ome->flip_normals(surface_list);
+ normal = test_face->normal_at(v_test); //(1,0, 0)
+ gti->delete_RefEntity(ref_faces.get());
+ surface_list.clean_out();
+
gti->delete_Body(body);
DLIList<BodySM*> bodysm_list;
DLIList<RefFace*> face_list;
- DLIList<Surface*> surface_list;
DLIList<RefVertex*> vertices;
for(int i = 0; i < faces_to_stitch.size(); i++)
{
@@ -416,7 +427,21 @@
bodies.append(tool_body);
gti->delete_Body(bodies);
+ //test flip_normal for a shell body.
from_body2 = gti->make_Body(bodysm);
+ test_body = gmti->copy_body(from_body2);
+ ref_faces.clean_out();
+ test_body->ref_faces(ref_faces);
+ normal = ref_faces.get()->normal_at(v1); //(1,0,0)
+ normal = ref_faces.step_and_get()->normal_at(v2); //(0,0,1)
+ surfaces.clean_out();
+ surfaces.append(ref_faces.step_and_get()->get_surface_ptr());
+ ome->flip_normals(surfaces);
+ normal = ref_faces.get()->normal_at(v1); //(-1,0,0)
+ normal = ref_faces.step_and_get()->normal_at(v2); //(0,0,1)
+ gti->delete_Body(test_body);
+ surfaces.clean_out();
+
tool_body = gmti->brick(4, 4, 4);
CubitVector v_move3(0,1,0);
More information about the cgma-dev
mailing list