cgma-dev
Threads by month
- ----- 2026 -----
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
March 2008
- 2 participants
- 17 discussions
Author: janehu
Date: 2008-03-31 13:03:49 -0500 (Mon, 31 Mar 2008)
New Revision: 1727
Modified:
cgm/trunk/geom/OCC/OCCLump.hpp
cgm/trunk/geom/OCC/OCCModifyEngine.cpp
cgm/trunk/geom/OCC/OCCQueryEngine.cpp
cgm/trunk/geom/OCC/OCCQueryEngine.hpp
Log:
Added for the case that a shell with multi-face imprinting on one single face case. In testing.
Modified: cgm/trunk/geom/OCC/OCCLump.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCLump.hpp 2008-03-31 17:46:33 UTC (rev 1726)
+++ cgm/trunk/geom/OCC/OCCLump.hpp 2008-03-31 18:03:49 UTC (rev 1727)
@@ -50,8 +50,6 @@
virtual ~OCCLump();
//- The destructor
- BodySM* body() {return myBodyPtr;}
-
void add_body(BodySM* new_body)
{myBodyPtr = new_body;}
Modified: cgm/trunk/geom/OCC/OCCModifyEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-03-31 17:46:33 UTC (rev 1726)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-03-31 18:03:49 UTC (rev 1727)
@@ -1060,18 +1060,24 @@
}
TopoDS_Shell aShell = aMakeShell.Shell();
- BRepBuilderAPI_MakeSolid aMakeSolid(aShell);
- if (!aMakeSolid.IsDone())
+ if(aShell.Closed())
{
- PRINT_ERROR("Cannot create an OCC Lump from the given surfaces.\n"
- "OCC internal error.\n");
- return (Lump *)NULL;
- }
+ BRepBuilderAPI_MakeSolid aMakeSolid(aShell);
+ if (!aMakeSolid.IsDone())
+ {
+ PRINT_ERROR("Cannot create an OCC Lump from the given surfaces.\n"
+ "OCC internal error.\n");
+ return (Lump *)NULL;
+ }
- TopoDS_Solid aSolid = aMakeSolid.Solid();
+ TopoDS_Solid aSolid = aMakeSolid.Solid();
- return
- OCCQueryEngine::instance()->populate_topology_bridge(aSolid, CUBIT_TRUE);
+ return
+ OCCQueryEngine::instance()->populate_topology_bridge(aSolid, CUBIT_TRUE);
+ }
+ OCCShell* occ_shell =
+ OCCQueryEngine::instance()->populate_topology_bridge(aShell, CUBIT_TRUE);
+ return occ_shell->my_lump();
}
//===============================================================================
@@ -1179,7 +1185,7 @@
if (lump == NULL)
return (BodySM*)NULL;
- return CAST_TO(lump, OCCLump)->body();
+ return CAST_TO(lump, OCCLump)->get_body();
}
@@ -1203,7 +1209,7 @@
if (lump == NULL)
return (BodySM*)NULL;
- return CAST_TO(lump, OCCLump)->body();
+ return CAST_TO(lump, OCCLump)->get_body();
}
@@ -1231,7 +1237,7 @@
if (lump == NULL)
return (BodySM*)NULL;
- return CAST_TO(lump, OCCLump)->body();
+ return CAST_TO(lump, OCCLump)->get_body();
}
//===============================================================================
@@ -1279,7 +1285,7 @@
if (lump == NULL)
return (BodySM*)NULL;
- return CAST_TO(lump, OCCLump)->body();
+ return CAST_TO(lump, OCCLump)->get_body();
}
@@ -1347,7 +1353,7 @@
return (BodySM*)NULL;
}
- return CAST_TO(lump, OCCLump)->body();
+ return CAST_TO(lump, OCCLump)->get_body();
}
//===============================================================================
@@ -1374,7 +1380,7 @@
return (BodySM*)NULL;
}
- return CAST_TO(lump, OCCLump)->body();
+ return CAST_TO(lump, OCCLump)->get_body();
}
//===============================================================================
@@ -1467,7 +1473,7 @@
lump = OCCQueryEngine::instance()->populate_topology_bridge(newSolid,
CUBIT_TRUE);
- return CAST_TO(lump, OCCLump)->body();
+ return CAST_TO(lump, OCCLump)->get_body();
}
//===============================================================================
@@ -1797,7 +1803,8 @@
//find the intersecting edges and faces.
int max_edge = 0;
- TopoDS_Face from_face, tool_face;
+ TopoDS_Face from_face,tool_face;
+ DLIList<TopoDS_Face*> tool_faces;
for(; intersector.MoreIntersection(); intersector.NextIntersection())
{
TopoDS_Shape face1 = intersector.ChangeFacesIntersector().Face(1);
@@ -1806,13 +1813,52 @@
TopTools_ListOfShape temp_list_of_edges;
temp_list_of_edges.Assign(section.SectionEdges());
int num_edges = temp_list_of_edges.Extent();
- if (max_edge < num_edges)
+ CubitBoolean is_same = face1.IsSame(from_face);
+ CubitBoolean is_same_tool_face = CUBIT_FALSE;
+ for (int j = 0; j < tool_faces.size(); j++)
+ {
+ if(face2.IsSame(*(tool_faces.get_and_step())))
+ {
+ is_same_tool_face = CUBIT_TRUE;
+ break;
+ }
+ }
+ if (max_edge < num_edges && !is_same)
{
list_of_edges.Assign(temp_list_of_edges);
max_edge = num_edges ;
from_face = TopoDS::Face(face1);
tool_face = TopoDS::Face(face2);
+ tool_faces.clean_out();
+ for(int i = 0 ; i < num_edges; i++)
+ tool_faces.append(&tool_face);
}
+ else if(num_edges == max_edge && is_same && !is_same_tool_face)
+ //multi tool faces cut the same face
+ {
+ TopTools_ListIteratorOfListOfShape Itor, temp_Itor;
+ temp_Itor.Initialize(temp_list_of_edges);
+ for(; temp_Itor.More(); temp_Itor.Next())
+ {
+ TopoDS_Edge temp_edge = TopoDS::Edge(temp_Itor.Value());
+ Itor.Initialize(list_of_edges);
+ CubitBoolean same_edge = CUBIT_FALSE;
+ for(; Itor.More(); Itor.Next())
+ {
+ TopoDS_Edge edge = TopoDS::Edge(Itor.Value());
+ if(edge.IsSame(temp_edge))
+ {
+ same_edge = CUBIT_TRUE;
+ break;
+ }
+ }
+ if(!same_edge)
+ {
+ list_of_edges.Append(temp_edge);
+ tool_faces.append(&(TopoDS::Face(face2)));
+ }
+ }
+ }
}
TopTools_ListIteratorOfListOfShape Itor;
@@ -1830,7 +1876,7 @@
{
TopoDS_Edge from_edge = TopoDS::Edge(Ex.Current());
TopOpeBRep_EdgesIntersector intersector;
- intersector.SetFaces(tool_face, from_face);
+ intersector.SetFaces(*(tool_faces.get_and_step()), from_face);
intersector.Perform(edge, from_edge);
int num_edges = intersector.NbSegments();
if(num_edges == 1) //overlap
Modified: cgm/trunk/geom/OCC/OCCQueryEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCQueryEngine.cpp 2008-03-31 17:46:33 UTC (rev 1726)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.cpp 2008-03-31 18:03:49 UTC (rev 1727)
@@ -1062,7 +1062,7 @@
DLIList<TopologyBridge*> OCCQueryEngine::populate_topology_bridge(TopoDS_Shape aShape)
{
DLIList<TopologyBridge*> tblist;
- // suitable to popolate for a TopoDS_CompSolid or TopoDS_Compound shape.
+ // suitable to populate for a TopoDS_CompSolid or TopoDS_Compound shape.
TopExp_Explorer Ex;
for (Ex.Init(aShape, TopAbs_COMPSOLID); Ex.More(); Ex.Next())
tblist.append(populate_topology_bridge(TopoDS::CompSolid(Ex.Current())));
@@ -1071,7 +1071,7 @@
{
Lump *lump =
populate_topology_bridge(TopoDS::Solid(Ex.Current()), CUBIT_TRUE);
- tblist.append(CAST_TO(lump, OCCLump)->body());
+ tblist.append(CAST_TO(lump, OCCLump)->get_body());
}
for (Ex.Init(aShape, TopAbs_SHELL, TopAbs_SOLID); Ex.More(); Ex.Next())
@@ -1545,8 +1545,8 @@
ShellSM* shell = CAST_TO(children.get_and_step(), ShellSM);
unhook_ShellSM_from_OCC(shell);
}
- if (occ_lump->body() != NULL)
- BodyList->remove(CAST_TO(occ_lump->body(), OCCBody));
+ if (occ_lump->get_body() != NULL)
+ BodyList->remove(CAST_TO(occ_lump->get_body(), OCCBody));
delete solid;
delete lump;
return CUBIT_SUCCESS;
Modified: cgm/trunk/geom/OCC/OCCQueryEngine.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCQueryEngine.hpp 2008-03-31 17:46:33 UTC (rev 1726)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.hpp 2008-03-31 18:03:49 UTC (rev 1727)
@@ -345,6 +345,8 @@
Curve* populate_topology_bridge(TopoDS_Edge aShape);
Point* populate_topology_bridge(TopoDS_Vertex aShape);
+ OCCShell* populate_topology_bridge(TopoDS_Shell aShape,
+ CubitBoolean standalone = CUBIT_FALSE );
DLIList<OCCBody*> *BodyList ;
DLIList<OCCSurface*> *SurfaceList ;
DLIList<OCCLoop*> *WireList; //standalone wire list
@@ -361,8 +363,6 @@
OCCLoop* populate_topology_bridge(TopoDS_Wire aShape,
CubitBoolean standalone = CUBIT_FALSE);
- OCCShell* populate_topology_bridge(TopoDS_Shell aShape,
- CubitBoolean standalone = CUBIT_FALSE );
CubitStatus write_topology( const char* file_name,
DLIList<OCCBody*> &facet_bodies,
1
0
Author: janehu
Date: 2008-03-28 14:25:35 -0500 (Fri, 28 Mar 2008)
New Revision: 1718
Modified:
cgm/trunk/geom/OCC/OCCModifyEngine.cpp
Log:
Now imprint_toposhape can handle following problems, all of them applies for
one face getting imprinted, because the imprint option is now only valid in
subtract function when no actual cutting happened.
1. Face cutting with two lines;
2. Face cutting with a open wire;
3. Face cutting with a closed wire.
It needs improvement for shell face imprinting and body body imprinting."
test passed the above 3 options.
Modified: cgm/trunk/geom/OCC/OCCModifyEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-03-28 18:02:52 UTC (rev 1717)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-03-28 19:25:35 UTC (rev 1718)
@@ -63,6 +63,7 @@
#include "BRepPrimAPI_MakeWedge.hxx"
#include "Handle_Geom_TrimmedCurve.hxx"
#include "Handle_Geom_RectangularTrimmedSurface.hxx"
+#include "TopOpeBRep_EdgesIntersector.hxx"
#include "TopExp_Explorer.hxx"
#include "OCCModifyEngine.hpp"
#include "OCCQueryEngine.hpp"
@@ -758,7 +759,8 @@
topo_edges_loops.clean_out();
CubitStatus stat = CUBIT_SUCCESS;
DLIList<TopoDS_Edge*>* topo_edges[curve_list.size()];
- for(int i = 0; i < curve_list.size(); i++)
+ int size_in = curve_list.size();
+ for(int i = 0; i < size_in; i++)
topo_edges[i] = new DLIList<TopoDS_Edge*>;
curve_list.reset() ;
@@ -770,12 +772,14 @@
OCCPoint* end = NULL;
DLIList<OCCPoint*> point_list;
double tol = OCCQueryEngine::instance()->get_sme_resabs_tolerance();
- CubitBoolean new_end = CUBIT_TRUE;
+ CubitBoolean new_end;
int size = curve_list.size();
int count = 0;
for ( int i = 0 ; i < size ; i++ )
{
+ if (i == 0)
+ new_end = CUBIT_TRUE;
for(int j = 0; j < curve_list.size(); j ++)
{
curve_ptr = curve_list.get() ;
@@ -800,12 +804,21 @@
}
if(end->is_equal(*(point_list.get()), tol) ||
- end->is_equal(*(point_list.step_and_get()),tol))
+ end->is_equal(*(point_list.step_and_get()),tol))
{
end = point_list.step_and_get();
new_end = CUBIT_TRUE;
break;
}
+
+ else if(start->is_equal(*(point_list.get()), tol) ||
+ start->is_equal(*(point_list.step_and_get()),tol))
+ {
+ start = end;
+ end = point_list.step_and_get();
+ new_end = CUBIT_TRUE;
+ break;
+ }
curve_list.step();
}
@@ -816,7 +829,7 @@
curve_list.remove();
if(start->is_equal( *end, tol)) //formed a closed loop
{
- i = 0;
+ i = -1;
size = curve_list.size() ;
topo_edges_loops.append(topo_edges[count]);
count++;
@@ -829,11 +842,22 @@
stat = CUBIT_FAILURE;
i = -1;
size = curve_list.size();
+ topo_edges_loops.append(topo_edges[count]);
+ count++;
}
}
if( new_end == CUBIT_FALSE ) //case of one disconnected curve
+ {
+ topo_edges_loops.append(topo_edges[count]);
stat = CUBIT_FAILURE;
+ }
+
+ for(int i = 0; i < size_in; i++)
+ {
+ if(topo_edges[i]->size() == 0)
+ delete topo_edges[i];
+ }
return stat;
}
//===============================================================================
@@ -1671,6 +1695,7 @@
double after_mass = myProps.Mass();
if((-after_mass + orig_mass) <= tol*tol*tol)
{
+ stat = CUBIT_FAILURE;
//Add imprint code here
if(imprint)
stat = imprint_toposhapes(from_shape, tool_shape);
@@ -1691,6 +1716,7 @@
double after_mass = myProps.Mass();
if((-after_mass + orig_mass) <= tol*tol)
{
+ stat = CUBIT_FAILURE;
//Add imprint code here
if(imprint)
stat = imprint_toposhapes(from_shape, tool_shape);
@@ -1761,6 +1787,7 @@
TopoDS_Shape* tool_shape)const
{
int num_cuts = 1;
+ CubitStatus stat = CUBIT_SUCCESS;
while(num_cuts)
{
TopOpeBRep_ShapeIntersector intersector;
@@ -1768,6 +1795,7 @@
BRepFeat_SplitShape splitor(*from_shape);
TopTools_ListOfShape list_of_edges;
+ //find the intersecting edges and faces.
int max_edge = 0;
TopoDS_Face from_face, tool_face;
for(; intersector.MoreIntersection(); intersector.NextIntersection())
@@ -1790,6 +1818,7 @@
TopTools_ListIteratorOfListOfShape Itor;
Itor.Initialize(list_of_edges);
DLIList<Curve*> curve_list;
+ CubitBoolean topo_changed = CUBIT_FALSE;
for(; Itor.More(); Itor.Next())
{
TopoDS_Edge edge = TopoDS::Edge(Itor.Value());
@@ -1800,31 +1829,28 @@
for (Ex.Init(from_face, TopAbs_EDGE); Ex.More(); Ex.Next())
{
TopoDS_Edge from_edge = TopoDS::Edge(Ex.Current());
- TopOpeBRep_ShapeIntersector intersector;
- intersector.InitIntersection(edge, from_edge, tool_face, from_face);
- for(; intersector.MoreIntersection(); intersector.NextIntersection())
- {
- TopoDS_Shape section_shape = intersector.CurrentGeomShape(1);
- TopExp_Explorer Ex;
- int num_edges = 0;
- for (Ex.Init(section_shape, TopAbs_EDGE); Ex.More(); Ex.Next())
- num_edges++;
- if(num_edges== 1) //overlap
+ TopOpeBRep_EdgesIntersector intersector;
+ intersector.SetFaces(tool_face, from_face);
+ intersector.Perform(edge, from_edge);
+ int num_edges = intersector.NbSegments();
+ if(num_edges == 1) //overlap
{
added = CUBIT_TRUE;
splitor.Add(edge, from_edge);
max_edge--;
break;
}
- }
- if(added)
- continue;
}
+ if(added)
+ {
+ topo_changed = CUBIT_TRUE;
+ continue;
+ }
Curve* curve = OCCQueryEngine::instance()->populate_topology_bridge(edge);
curve_list.append(curve);
}
DLIList<DLIList<TopoDS_Edge*>*> edge_lists;
- if (max_edge > 1)
+ if (max_edge >= 1)
{
sort_curves(curve_list, edge_lists);
DLIList<TopoDS_Edge*>* edge_list;
@@ -1836,11 +1862,17 @@
myWire.Add(e);
}
splitor.Add(myWire.Wire(),from_face);
+ topo_changed = CUBIT_TRUE;
}
- splitor.Build();
- if(splitor.IsDone())
- delete from_shape;
- from_shape = new TopoDS_Shape(splitor.Shape());
+ if(topo_changed)
+ {
+ splitor.Build();
+ if(splitor.IsDone())
+ delete from_shape;
+ from_shape = new TopoDS_Shape(splitor.Shape());
+ }
+ else
+ stat = CUBIT_FAILURE;
if(edge_lists.size()==0)
num_cuts--;
}
@@ -1853,7 +1885,7 @@
num_face++;
}
*/
- return CUBIT_SUCCESS;
+ return stat;
}
//===============================================================================
// Function : imprint
1
0
Author: janehu
Date: 2008-03-27 13:53:17 -0500 (Thu, 27 Mar 2008)
New Revision: 1710
Modified:
cgm/trunk/geom/OCC/OCCModifyEngine.cpp
cgm/trunk/test/modify.cpp
Log:
Added for cylinder function to create a ellipse based cone;test passed this; modified for imprint_toposhapes, still the overlapping of edges status is to be improved to make the code work automatically. If I go into debugger and hand choose edges to cut the face, it works.
Modified: cgm/trunk/geom/OCC/OCCModifyEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-03-27 17:39:57 UTC (rev 1709)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-03-27 18:53:17 UTC (rev 1710)
@@ -40,7 +40,9 @@
#include "Handle_Geom_Plane.hxx"
#include "BRepPrimAPI_MakePrism.hxx"
#include "BRepPrimAPI_MakeCone.hxx"
+#include "BRepOffsetAPI_ThruSections.hxx"
#include "BRepPrimAPI_MakeTorus.hxx"
+#include "BRepPrimAPI_MakeCylinder.hxx"
#include "GC_MakeEllipse.hxx"
#include "BRepBuilderAPI_MakeEdge.hxx"
#include "BRepAdaptor_Surface.hxx"
@@ -751,10 +753,10 @@
// Date : 03/08
//===============================================================================
CubitStatus OCCModifyEngine::sort_curves(DLIList<Curve*> curve_list,
- DLIList<DLIList<TopoDS_Edge*>*>& topo_edges_loops)const
+ DLIList<DLIList<TopoDS_Edge*>*>& topo_edges_loops)const
{
topo_edges_loops.clean_out();
-
+ CubitStatus stat = CUBIT_SUCCESS;
DLIList<TopoDS_Edge*>* topo_edges[curve_list.size()];
for(int i = 0; i < curve_list.size(); i++)
topo_edges[i] = new DLIList<TopoDS_Edge*>;
@@ -824,19 +826,15 @@
}
else
{
- PRINT_ERROR("In OCCModifyEngine::sort_curves\n"
- " Curve list can't form closed loops \n") ;
- return CUBIT_FAILURE;
+ stat = CUBIT_FAILURE;
+ i = -1;
+ size = curve_list.size();
}
}
if( new_end == CUBIT_FALSE ) //case of one disconnected curve
- {
- PRINT_ERROR("In OCCModifyEngine::sort_curves\n"
- " Curve list can't form closed loops \n") ;
- return CUBIT_FAILURE;
- }
- return CUBIT_SUCCESS;
+ stat = CUBIT_FAILURE;
+ return stat;
}
//===============================================================================
// Function : make_TopoDS_Face
@@ -1272,14 +1270,8 @@
//===============================================================================
BodySM* OCCModifyEngine::cylinder( double hi, double r1, double r2, double r3 ) const
{
- if(r2 > 0 && r3 > 0)
- {
- PRINT_WARNING("Can not make elliptical cone for OCC engine.\n");
- return (BodySM*) NULL;
- }
-
TopoDS_Solid S;
- if(r3 == 0)//elliptical based cylinder
+ if(r2 != r1)//elliptical based cylinder
{
gp_Pnt center(0.0, 0.0, 0.0);
gp_Dir main_dir(0.0, 0.0, 1.0);
@@ -1290,23 +1282,36 @@
BRepBuilderAPI_MakeWire aWire(new_edge);
TopoDS_Wire test_Wire = aWire.Wire();
-
- BRepBuilderAPI_MakeFace made_face(test_Wire);
-
- if (!made_face.IsDone())
+
+ BRepOffsetAPI_ThruSections builder(CUBIT_TRUE, CUBIT_TRUE);
+ builder.AddWire(test_Wire);
+ if (r3 == 0)
{
- PRINT_ERROR("In OCCModifyEngine::cylinder\n"
- " Cannot create elliptical surface for given radii.\n");
- return (BodySM *)NULL;
+ gp_Pnt pt = gp_Pnt( 0.0, 0.0, hi);
+ TopoDS_Vertex theVertex = BRepBuilderAPI_MakeVertex(pt);
+ builder.AddVertex(theVertex);
}
- TopoDS_Face test_face = made_face.Face();
- gp_Vec V(0.0, 0.0, hi);
- TopoDS_Shape S1 = BRepPrimAPI_MakePrism(test_face, V);
- S = TopoDS::Solid(S1);
+ else
+ {
+ gp_Pnt center2(0.0, 0.0,hi);
+ gp_Ax2 Axis2(center2, main_dir, x_dir);
+ Handle(Geom_Curve) curve_ptr = GC_MakeEllipse(Axis2, r3, r3*r2/r1);
+ TopoDS_Edge new_edge = BRepBuilderAPI_MakeEdge(curve_ptr);
+ BRepBuilderAPI_MakeWire aWire(new_edge);
+ TopoDS_Wire test_Wire = aWire.Wire();
+ builder.AddWire(test_Wire);
+ }
+ builder.Build() ;
+ S = TopoDS::Solid(builder.Shape());
}
else // cone
- S = BRepPrimAPI_MakeCone(r1, r3, hi);
+ {
+ if(r1 == r3) //cylinder
+ S = BRepPrimAPI_MakeCylinder(r1, hi);
+ else
+ S = BRepPrimAPI_MakeCone(r1, r3, hi);
+ }
Lump* lump = OCCQueryEngine::instance()->populate_topology_bridge(S,
CUBIT_TRUE);
@@ -1531,7 +1536,6 @@
bool imprint,
bool keep_old) const
{
- //need to implement "imprint" function.
// copy the bodies in case subtraction has some errors
DLIList<TopoDS_Shape*> tool_bodies_copy;
DLIList<TopoDS_Shape*> from_bodies_copy;
@@ -1756,67 +1760,90 @@
CubitStatus OCCModifyEngine::imprint_toposhapes(TopoDS_Shape*& from_shape,
TopoDS_Shape* tool_shape)const
{
- TopOpeBRep_ShapeIntersector intersector;
- intersector.InitIntersection(*from_shape, *tool_shape);
- BRepFeat_SplitShape splitor(*from_shape);
- TopTools_ListOfShape list_of_edges;
-
- int max_edge = 0;
- TopoDS_Shape from_face;
- for(; intersector.MoreIntersection(); intersector.NextIntersection())
+ int num_cuts = 1;
+ while(num_cuts)
{
- TopoDS_Shape face1 = intersector.ChangeFacesIntersector().Face(1);
- TopoDS_Shape face2 = intersector.ChangeFacesIntersector().Face(2);
- BRepAlgoAPI_Section section(face1, face2);
- TopTools_ListOfShape temp_list_of_edges;
- temp_list_of_edges.Assign(section.SectionEdges());
- int num_edges = temp_list_of_edges.Extent();
- if (max_edge < num_edges)
- {
- list_of_edges.Assign(temp_list_of_edges);
- max_edge = num_edges ;
- from_face = face1;
- }
- }
+ TopOpeBRep_ShapeIntersector intersector;
+ intersector.InitIntersection(*from_shape, *tool_shape);
+ BRepFeat_SplitShape splitor(*from_shape);
+ TopTools_ListOfShape list_of_edges;
- TopTools_ListIteratorOfListOfShape Itor;
- Itor.Initialize(list_of_edges);
- DLIList<Curve*> curve_list;
- for(; Itor.More(); Itor.Next())
- {
- TopoDS_Edge edge = TopoDS::Edge(Itor.Value());
- if (max_edge == 1) //surface solid imprint
- {
- splitor.Add(edge, TopoDS::Face(from_face));
- break;
- }
- Curve* curve = OCCQueryEngine::instance()->populate_topology_bridge(edge);
- curve_list.append(curve);
+ int max_edge = 0;
+ TopoDS_Face from_face, tool_face;
+ for(; intersector.MoreIntersection(); intersector.NextIntersection())
+ {
+ TopoDS_Shape face1 = intersector.ChangeFacesIntersector().Face(1);
+ TopoDS_Shape face2 = intersector.ChangeFacesIntersector().Face(2);
+ BRepAlgoAPI_Section section(face1, face2);
+ TopTools_ListOfShape temp_list_of_edges;
+ temp_list_of_edges.Assign(section.SectionEdges());
+ int num_edges = temp_list_of_edges.Extent();
+ if (max_edge < num_edges)
+ {
+ list_of_edges.Assign(temp_list_of_edges);
+ max_edge = num_edges ;
+ from_face = TopoDS::Face(face1);
+ tool_face = TopoDS::Face(face2);
+ }
+ }
+
+ TopTools_ListIteratorOfListOfShape Itor;
+ Itor.Initialize(list_of_edges);
+ DLIList<Curve*> curve_list;
+ for(; Itor.More(); Itor.Next())
+ {
+ TopoDS_Edge edge = TopoDS::Edge(Itor.Value());
+ //check if the edge is on from_face edges, add such edge on existing
+ //edge to split it.
+ TopExp_Explorer Ex;
+ CubitBoolean added = CUBIT_FALSE;
+ for (Ex.Init(from_face, TopAbs_EDGE); Ex.More(); Ex.Next())
+ {
+ TopoDS_Edge from_edge = TopoDS::Edge(Ex.Current());
+ TopOpeBRep_ShapeIntersector intersector;
+ intersector.InitIntersection(edge, from_edge, tool_face, from_face);
+ for(; intersector.MoreIntersection(); intersector.NextIntersection())
+ {
+ TopoDS_Shape section_shape = intersector.CurrentGeomShape(1);
+ TopExp_Explorer Ex;
+ int num_edges = 0;
+ for (Ex.Init(section_shape, TopAbs_EDGE); Ex.More(); Ex.Next())
+ num_edges++;
+ if(num_edges== 1) //overlap
+ {
+ added = CUBIT_TRUE;
+ splitor.Add(edge, from_edge);
+ max_edge--;
+ break;
+ }
+ }
+ if(added)
+ continue;
+ }
+ Curve* curve = OCCQueryEngine::instance()->populate_topology_bridge(edge);
+ curve_list.append(curve);
+ }
+ DLIList<DLIList<TopoDS_Edge*>*> edge_lists;
+ if (max_edge > 1)
+ {
+ sort_curves(curve_list, edge_lists);
+ DLIList<TopoDS_Edge*>* edge_list;
+ edge_list = edge_lists.pop();
+ BRepBuilderAPI_MakeWire myWire;
+ for(int i = 0; i < edge_list->size(); i++)
+ {
+ TopoDS_Edge e = *(edge_list->get_and_step());
+ myWire.Add(e);
+ }
+ splitor.Add(myWire.Wire(),from_face);
+ }
+ splitor.Build();
+ if(splitor.IsDone())
+ delete from_shape;
+ from_shape = new TopoDS_Shape(splitor.Shape());
+ if(edge_lists.size()==0)
+ num_cuts--;
}
- if (max_edge > 1)
- {
- DLIList<DLIList<TopoDS_Edge*>*> edge_lists;
- CubitStatus stat = sort_curves(curve_list, edge_lists);
- if (!stat)
- {
- PRINT_ERROR("can't do solid solid imprint without a closed loop.\n");
- return CUBIT_FAILURE;
- }
- assert(edge_lists.size() == 1);
- DLIList<TopoDS_Edge*>* edge_list;
- edge_list = edge_lists.get();
- BRepBuilderAPI_MakeWire myWire;
- for(int i = 0; i < edge_list->size(); i++)
- {
- TopoDS_Edge e = *(edge_list->get_and_step());
- myWire.Add(e);
- }
- splitor.Add(myWire.Wire(),TopoDS::Face(from_face));
- }
- splitor.Build();
- if(splitor.IsDone())
- delete from_shape;
- from_shape = new TopoDS_Shape(splitor.Shape());
/*
TopExp_Explorer Ex;
int num_face = 0;
Modified: cgm/trunk/test/modify.cpp
===================================================================
--- cgm/trunk/test/modify.cpp 2008-03-27 17:39:57 UTC (rev 1709)
+++ cgm/trunk/test/modify.cpp 2008-03-27 18:53:17 UTC (rev 1710)
@@ -183,14 +183,33 @@
gti->delete_RefEntity( free_entities.get_and_step());
}
+ //test for cylinder making
+ Body* from_body = gmti->cylinder(10, 4, 3, 2);
+ Body* from_body2 = gmti->cylinder(8, 4, 2, 0);
+ Body* tool_body = gmti->cylinder(10, 1, 1, 1);
+ double d;
+ d = from_body->measure(); //d = 219.91
+ d = from_body2->measure();//d = 67.02
+ d = tool_body->measure(); //d = 31.41
+
+ bodies.clean_out();
+ gti->bodies(bodies);
+ //delete all entities
+ gti->delete_Body(bodies);
+
//test for subtract
- Body* from_body = gmti->brick(10, 10, 10);
- Body* tool_body = gmti->brick(1, 1, 1);
+ from_body = gmti->brick(10, 10, 10);
+ from_body2 = gmti->brick(4, 4, 4);
+ tool_body = gmti->brick(1, 1, 1);
+ CubitVector v_move(1,0,0);
+ gti->translate(from_body2,v_move);
DLIList<Body*> from_bodies;
from_bodies.append(from_body);
+ from_bodies.append(from_body2);
DLIList<Body*> new_bodies;
rsl = gmti->subtract(tool_body, from_bodies, new_bodies,
- CUBIT_FALSE, CUBIT_FALSE);
- double d = new_bodies.get()->measure();
+ CUBIT_TRUE, CUBIT_FALSE);
+ d = new_bodies.step_and_get()->measure();
+ v = new_bodies.get()->center_point();
return stat;
}
1
0
Author: janehu
Date: 2008-03-25 14:11:16 -0500 (Tue, 25 Mar 2008)
New Revision: 1697
Modified:
cgm/trunk/geom/OCC/OCCModifyEngine.cpp
Log:
Modified sort_curves and imprint_toposhapes, now the technical question up to solve is when we get the cutting edges, how do we know if the edge is overlapping with the original surface's edges, if so, we don't need to add them into the cutting tool.
Modified: cgm/trunk/geom/OCC/OCCModifyEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-03-25 18:36:19 UTC (rev 1696)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-03-25 19:11:16 UTC (rev 1697)
@@ -751,11 +751,14 @@
// Date : 03/08
//===============================================================================
CubitStatus OCCModifyEngine::sort_curves(DLIList<Curve*> curve_list,
- DLIList<DLIList<TopoDS_Edge*>*>& topo_edges_loops)const
+ DLIList<DLIList<TopoDS_Edge*>*>& topo_edges_loops)const
{
topo_edges_loops.clean_out();
- DLIList<TopoDS_Edge*> topo_edges[curve_list.size()];
+ DLIList<TopoDS_Edge*>* topo_edges[curve_list.size()];
+ for(int i = 0; i < curve_list.size(); i++)
+ topo_edges[i] = new DLIList<TopoDS_Edge*>;
+
curve_list.reset() ;
Curve const* curve_ptr = NULL ;
OCCCurve* occ_curve = NULL;
@@ -801,18 +804,19 @@
new_end = CUBIT_TRUE;
break;
}
+ curve_list.step();
}
if (new_end)//found next curve
{
topo_edge = occ_curve->get_TopoDS_Edge();
- topo_edges[count].append(topo_edge);
+ topo_edges[count]->append(topo_edge);
curve_list.remove();
if(start->is_equal( *end, tol)) //formed a closed loop
{
i = 0;
size = curve_list.size() ;
- topo_edges_loops.append(&topo_edges[count]);
+ topo_edges_loops.append(topo_edges[count]);
count++;
}
else
@@ -1653,6 +1657,7 @@
TopoDS_Shape cut_shape = BRepAlgoAPI_Cut(*from_shape, *tool_shape);
//compare to see if the from_shape has gotten cut.
+ CubitStatus stat;
if(is_volume[i])
{
GProp_GProps myProps;
@@ -1664,8 +1669,12 @@
{
//Add imprint code here
if(imprint)
- imprint_toposhapes(from_shape, tool_shape);
- count++;
+ stat = imprint_toposhapes(from_shape, tool_shape);
+ if(!stat)
+ {
+ PRINT_ERROR("Can't do imprint operation on the body. \n");
+ count++;
+ }
continue;
}
}
@@ -1680,8 +1689,12 @@
{
//Add imprint code here
if(imprint)
- imprint_toposhapes(from_shape, tool_shape);
- count++;
+ stat = imprint_toposhapes(from_shape, tool_shape);
+ if(!stat)
+ {
+ PRINT_ERROR("Can't do imprint operation on the body. \n");
+ count++;
+ }
continue;
}
}
@@ -1690,7 +1703,7 @@
}
//ok, we're done wih all cuts, construct new Body'
- if (count < tool_body_list.size())
+ if (count < tool_body_list.size() )
tbs += OCCQueryEngine::instance()->populate_topology_bridge(*from_shape);
else
{
@@ -1745,50 +1758,75 @@
{
TopOpeBRep_ShapeIntersector intersector;
intersector.InitIntersection(*from_shape, *tool_shape);
+ BRepFeat_SplitShape splitor(*from_shape);
TopTools_ListOfShape list_of_edges;
- BRepFeat_SplitShape splitor(*from_shape);
+ int max_edge = 0;
+ TopoDS_Shape from_face;
for(; intersector.MoreIntersection(); intersector.NextIntersection())
{
TopoDS_Shape face1 = intersector.ChangeFacesIntersector().Face(1);
TopoDS_Shape face2 = intersector.ChangeFacesIntersector().Face(2);
BRepAlgoAPI_Section section(face1, face2);
- list_of_edges.Assign(section.SectionEdges());
- int num_edges = list_of_edges.Extent();
+ TopTools_ListOfShape temp_list_of_edges;
+ temp_list_of_edges.Assign(section.SectionEdges());
+ int num_edges = temp_list_of_edges.Extent();
+ if (max_edge < num_edges)
+ {
+ list_of_edges.Assign(temp_list_of_edges);
+ max_edge = num_edges ;
+ from_face = face1;
+ }
+ }
- TopTools_ListIteratorOfListOfShape Itor;
- Itor.Initialize(list_of_edges);
- DLIList<Curve*> curve_list;
- for(; Itor.More(); Itor.Next())
+ TopTools_ListIteratorOfListOfShape Itor;
+ Itor.Initialize(list_of_edges);
+ DLIList<Curve*> curve_list;
+ for(; Itor.More(); Itor.Next())
+ {
+ TopoDS_Edge edge = TopoDS::Edge(Itor.Value());
+ if (max_edge == 1) //surface solid imprint
{
- TopoDS_Edge edge = TopoDS::Edge(Itor.Value());
- if (num_edges == 1) //surface solid imprint
- {
- splitor.Add(edge, TopoDS::Face(face1));
- break;
- }
- Curve* curve = OCCQueryEngine::instance()->populate_topology_bridge(edge);
- curve_list.append(curve);
+ splitor.Add(edge, TopoDS::Face(from_face));
+ break;
}
- if (num_edges > 1)
- {
- DLIList<DLIList<TopoDS_Edge*>*> edge_lists;
- CubitStatus stat = sort_curves(curve_list, edge_lists);
- if (!stat)
- {
- PRINT_ERROR("can't do solid solid imprint without a closed loop.\n");
- return CUBIT_FAILURE;
- }
- assert(edge_lists.size() == 1);
- DLIList<TopoDS_Edge*> edge_list;
- edge_list = *(edge_lists.get());
- BRepBuilderAPI_MakeWire myWire;
- for(int i = 0; i < edge_list.size(); i++)
- myWire.Add(*(edge_list.get_and_step()));
- splitor.Add(TopoDS::Wire(myWire.Shape()),TopoDS::Face(face1));
+ Curve* curve = OCCQueryEngine::instance()->populate_topology_bridge(edge);
+ curve_list.append(curve);
+ }
+ if (max_edge > 1)
+ {
+ DLIList<DLIList<TopoDS_Edge*>*> edge_lists;
+ CubitStatus stat = sort_curves(curve_list, edge_lists);
+ if (!stat)
+ {
+ PRINT_ERROR("can't do solid solid imprint without a closed loop.\n");
+ return CUBIT_FAILURE;
+ }
+ assert(edge_lists.size() == 1);
+ DLIList<TopoDS_Edge*>* edge_list;
+ edge_list = edge_lists.get();
+ BRepBuilderAPI_MakeWire myWire;
+ for(int i = 0; i < edge_list->size(); i++)
+ {
+ TopoDS_Edge e = *(edge_list->get_and_step());
+ myWire.Add(e);
}
- splitor.Build();
+ splitor.Add(myWire.Wire(),TopoDS::Face(from_face));
}
+ splitor.Build();
+ if(splitor.IsDone())
+ delete from_shape;
+ from_shape = new TopoDS_Shape(splitor.Shape());
+ /*
+ TopExp_Explorer Ex;
+ int num_face = 0;
+ for (Ex.Init(*from_shape, TopAbs_FACE); Ex.More(); Ex.Next())
+ {
+ TopoDS_Face face = TopoDS::Face(Ex.Current());
+ num_face++;
+ }
+ */
+ return CUBIT_SUCCESS;
}
//===============================================================================
// Function : imprint
1
0
Author: janehu
Date: 2008-03-21 11:59:20 -0500 (Fri, 21 Mar 2008)
New Revision: 1677
Modified:
cgm/trunk/geom/OCC/OCCModifyEngine.cpp
cgm/trunk/geom/OCC/OCCModifyEngine.hpp
Log:
Separated the sort_curves funtion, and used it in imprint_toposhapes; Added for imprint_toposhapes; Viewed the discussion on the OCC forum about it, this function of spliting surfaces is not guaranteed to work yet. At least not from the forum, no details on the document found.
Modified: cgm/trunk/geom/OCC/OCCModifyEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-03-21 15:20:14 UTC (rev 1676)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-03-21 16:59:20 UTC (rev 1677)
@@ -67,7 +67,9 @@
#include "CubitMessage.hpp"
#include "CubitDefines.h"
#include "TopTools_DataMapOfShapeInteger.hxx"
+#include "BRepFeat_SplitShape.hxx"
#include "TopOpeBRep_ShapeIntersector.hxx"
+#include "TopTools_ListIteratorOfListOfShape.hxx"
#include "CubitUtil.hpp"
#include "CubitPoint.hpp"
#include "CubitPointData.hpp"
@@ -659,12 +661,8 @@
bool check_edges) const
{
//Create TopoDS_Edge list to make a surface.
- DLIList<TopoDS_Edge*> topo_edges[curve_list.size()];
DLIList<DLIList<TopoDS_Edge*>*> topo_edges_loops;
curve_list.reset() ;
- Curve const* curve_ptr = NULL ;
- OCCCurve* occ_curve = NULL;
- TopoDS_Edge* topo_edge = NULL;
//check no intersections of the TopoDS_Edge's.
//need to check that no intersection in the middle of the curves, not at
@@ -723,26 +721,66 @@
return (Surface *)NULL;
}
- //sort the curves so they are in order and make closed loop
+ CubitStatus stat = sort_curves(curve_list, topo_edges_loops);
+ if( stat == CUBIT_FAILURE ) //case of one disconnected curve
+ return (Surface*) NULL;
+
+ // Use the topo_edges to make a topo_face
+ const TopoDS_Face* topo_face = make_TopoDS_Face(surface_type,
+ topo_edges_loops, old_surface_ptr) ;
+
+ if(topo_face == NULL)
+ {
+ PRINT_ERROR("In OCCModifyEngine::make_Surface\n"
+ " Cannot make Surface object.\n");
+ return (Surface *)NULL;
+ }
+
+ // make the topology bridges for the face
+ TopoDS_Face the_face = *topo_face;
+ Surface *surface = OCCQueryEngine::instance()->populate_topology_bridge(
+ the_face, CUBIT_TRUE);
+ return surface ;
+}
+
+//===============================================================================
+// Function : sort_curves
+// Member Type: PROTECTED
+// Description: sort the curves so they are in order and make closed loop
+// Author : Jane Hu
+// Date : 03/08
+//===============================================================================
+CubitStatus OCCModifyEngine::sort_curves(DLIList<Curve*> curve_list,
+ DLIList<DLIList<TopoDS_Edge*>*>& topo_edges_loops)const
+{
+ topo_edges_loops.clean_out();
+
+ DLIList<TopoDS_Edge*> topo_edges[curve_list.size()];
+ curve_list.reset() ;
+ Curve const* curve_ptr = NULL ;
+ OCCCurve* occ_curve = NULL;
+ TopoDS_Edge* topo_edge = NULL;
+
OCCPoint* start = NULL;
OCCPoint* end = NULL;
DLIList<OCCPoint*> point_list;
double tol = OCCQueryEngine::instance()->get_sme_resabs_tolerance();
CubitBoolean new_end = CUBIT_TRUE;
int size = curve_list.size();
- count = 0;
+
+ int count = 0;
for ( int i = 0 ; i < size ; i++ )
{
for(int j = 0; j < curve_list.size(); j ++)
{
- curve_ptr = curve_list.get() ;
+ curve_ptr = curve_list.get() ;
occ_curve = CAST_TO(const_cast<Curve*>(curve_ptr), OCCCurve);
if(occ_curve == NULL)
{
- PRINT_ERROR("In OCCModifyEngine::make_Surface\n"
+ PRINT_ERROR("In OCCModifyEngine::sort_curves\n"
" Got a NULL pointer to OCCCurve\n") ;
- return (Surface*) NULL;
+ return CUBIT_FAILURE;
}
point_list.clean_out();
@@ -750,72 +788,55 @@
//assert(point_list.size()==2);
if (i == 0)
- {
+ {
start = point_list.get();
- end = point_list.pop();
+ end = point_list.pop();
break;
}
if(end->is_equal(*(point_list.get()), tol) ||
- end->is_equal(*(point_list.step_and_get()),tol))
- {
- end = point_list.step_and_get();
- new_end = CUBIT_TRUE;
+ end->is_equal(*(point_list.step_and_get()),tol))
+ {
+ end = point_list.step_and_get();
+ new_end = CUBIT_TRUE;
break;
- }
+ }
}
- if (new_end)//found next curve
+ if (new_end)//found next curve
{
topo_edge = occ_curve->get_TopoDS_Edge();
topo_edges[count].append(topo_edge);
- curve_list.remove();
+ curve_list.remove();
if(start->is_equal( *end, tol)) //formed a closed loop
{
- i = 0;
- size = curve_list.size() ;
+ i = 0;
+ size = curve_list.size() ;
topo_edges_loops.append(&topo_edges[count]);
count++;
- }
+ }
else
new_end = CUBIT_FALSE;
}
else
{
- PRINT_ERROR("In OCCModifyEngine::make_Surface\n"
+ PRINT_ERROR("In OCCModifyEngine::sort_curves\n"
" Curve list can't form closed loops \n") ;
- return (Surface*) NULL;
+ return CUBIT_FAILURE;
}
}
-
- if( new_end == CUBIT_FALSE ) //case of one disconnected curve
+
+ if( new_end == CUBIT_FALSE ) //case of one disconnected curve
{
- PRINT_ERROR("In OCCModifyEngine::make_Surface\n"
+ PRINT_ERROR("In OCCModifyEngine::sort_curves\n"
" Curve list can't form closed loops \n") ;
- return (Surface*) NULL;
+ return CUBIT_FAILURE;
}
-
- // Use the topo_edges to make a topo_face
- const TopoDS_Face* topo_face = make_TopoDS_Face(surface_type,
- topo_edges_loops, old_surface_ptr) ;
-
- if(topo_face == NULL)
- {
- PRINT_ERROR("In OCCModifyEngine::make_Surface\n"
- " Cannot make Surface object.\n");
- return (Surface *)NULL;
- }
-
- // make the topology bridges for the face
- TopoDS_Face the_face = *topo_face;
- Surface *surface = OCCQueryEngine::instance()->populate_topology_bridge(
- the_face, CUBIT_TRUE);
- return surface ;
-}
-
+ return CUBIT_SUCCESS;
+}
//===============================================================================
// Function : make_TopoDS_Face
-// Member Type: PUBLIC
+// Member Type: PROTECTED
// Description: make a opoDS_Face of type surface_type, given the list of
// TopoDS_Edge. the TopoDS_Edge's should be in order in loops.
// check edges option is done in GeometryModifyTool level, so
@@ -1631,7 +1652,7 @@
//bodies overlap, proceed with the subtract
TopoDS_Shape cut_shape = BRepAlgoAPI_Cut(*from_shape, *tool_shape);
- //compare to see if the from_shape is getting cut.
+ //compare to see if the from_shape has gotten cut.
if(is_volume[i])
{
GProp_GProps myProps;
@@ -1686,7 +1707,7 @@
if ((100 - frac_done) < fraction_remaining)
{
fraction_remaining = 100 - frac_done;
- PRINT_INFO("%d% remaining.\n ", fraction_remaining+1);
+ PRINT_INFO("%d\% remaining.\n ", fraction_remaining+1);
}
}
}
@@ -1698,7 +1719,7 @@
new_bodies.append(bodysm);
}
- //ok, we're done wih all cuts, construct new Body's
+ //ok, we're done wih all cuts, delete unnecessaries.
while (tool_boxes.size())
delete tool_boxes.pop();
while (tool_bodies_copy.size())
@@ -1712,18 +1733,61 @@
return CUBIT_SUCCESS;
}
+//===============================================================================
+// Function : imprint_toposhapes
+// Member Type: PROTECTED
+// Description: imprint boolean operation on OCC-based bodies
+// Author : Jane HU
+// Date : 03/08
+//===============================================================================
CubitStatus OCCModifyEngine::imprint_toposhapes(TopoDS_Shape*& from_shape,
TopoDS_Shape* tool_shape)const
{
TopOpeBRep_ShapeIntersector intersector;
intersector.InitIntersection(*from_shape, *tool_shape);
TopTools_ListOfShape list_of_edges;
+ BRepFeat_SplitShape splitor(*from_shape);
+
for(; intersector.MoreIntersection(); intersector.NextIntersection())
{
TopoDS_Shape face1 = intersector.ChangeFacesIntersector().Face(1);
TopoDS_Shape face2 = intersector.ChangeFacesIntersector().Face(2);
BRepAlgoAPI_Section section(face1, face2);
list_of_edges.Assign(section.SectionEdges());
+ int num_edges = list_of_edges.Extent();
+
+ TopTools_ListIteratorOfListOfShape Itor;
+ Itor.Initialize(list_of_edges);
+ DLIList<Curve*> curve_list;
+ for(; Itor.More(); Itor.Next())
+ {
+ TopoDS_Edge edge = TopoDS::Edge(Itor.Value());
+ if (num_edges == 1) //surface solid imprint
+ {
+ splitor.Add(edge, TopoDS::Face(face1));
+ break;
+ }
+ Curve* curve = OCCQueryEngine::instance()->populate_topology_bridge(edge);
+ curve_list.append(curve);
+ }
+ if (num_edges > 1)
+ {
+ DLIList<DLIList<TopoDS_Edge*>*> edge_lists;
+ CubitStatus stat = sort_curves(curve_list, edge_lists);
+ if (!stat)
+ {
+ PRINT_ERROR("can't do solid solid imprint without a closed loop.\n");
+ return CUBIT_FAILURE;
+ }
+ assert(edge_lists.size() == 1);
+ DLIList<TopoDS_Edge*> edge_list;
+ edge_list = *(edge_lists.get());
+ BRepBuilderAPI_MakeWire myWire;
+ for(int i = 0; i < edge_list.size(); i++)
+ myWire.Add(*(edge_list.get_and_step()));
+ splitor.Add(TopoDS::Wire(myWire.Shape()),TopoDS::Face(face1));
+ }
+ splitor.Build();
}
}
//===============================================================================
Modified: cgm/trunk/geom/OCC/OCCModifyEngine.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.hpp 2008-03-21 15:20:14 UTC (rev 1676)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.hpp 2008-03-21 16:59:20 UTC (rev 1677)
@@ -660,6 +660,9 @@
Surface* old_surface_ptr) const;
CubitStatus imprint_toposhapes(TopoDS_Shape*&, TopoDS_Shape*) const;
+
+ CubitStatus sort_curves(DLIList<Curve*> curve_list,
+ DLIList<DLIList<TopoDS_Edge*>*>& topo_edges_loops)const;
private:
} ;
1
0
Author: janehu
Date: 2008-03-20 13:50:32 -0500 (Thu, 20 Mar 2008)
New Revision: 1674
Modified:
cgm/trunk/geom/OCC/OCCModifyEngine.cpp
cgm/trunk/geom/OCC/OCCModifyEngine.hpp
Log:
Added check to determine if the subtract operation is actually performed, if did not perform, don't change the original BodySM; Added part of impritn_toposhapes, investigating on splitshape in OCC.
Modified: cgm/trunk/geom/OCC/OCCModifyEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-03-19 19:15:46 UTC (rev 1673)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-03-20 18:50:32 UTC (rev 1674)
@@ -55,6 +55,7 @@
#include "TopologyBridge.hpp"
#include "BRepAlgoAPI_Fuse.hxx"
#include "BRepAlgoAPI_Cut.hxx"
+#include "BRepAlgoAPI_Section.hxx"
#include "BRepPrimAPI_MakeSphere.hxx"
#include "BRepPrimAPI_MakeBox.hxx"
#include "BRepPrimAPI_MakeWedge.hxx"
@@ -66,6 +67,7 @@
#include "CubitMessage.hpp"
#include "CubitDefines.h"
#include "TopTools_DataMapOfShapeInteger.hxx"
+#include "TopOpeBRep_ShapeIntersector.hxx"
#include "CubitUtil.hpp"
#include "CubitPoint.hpp"
#include "CubitPointData.hpp"
@@ -1508,12 +1510,14 @@
// copy the bodies in case subtraction has some errors
DLIList<TopoDS_Shape*> tool_bodies_copy;
DLIList<TopoDS_Shape*> from_bodies_copy;
+ DLIList<CubitBoolean> is_volume;
for (int i = 0; i < from_bodies.size(); i++)
{
BodySM* body = from_bodies.get_and_step();
OCCBody* occ_body = CAST_TO(body, OCCBody);
OCCSurface* surface = occ_body->my_sheet_surface();
OCCShell* shell = occ_body->shell();
+ is_volume.append( CUBIT_TRUE);
if(surface)
{
TopoDS_Face* topo_face = surface->get_TopoDS_Face();
@@ -1521,6 +1525,7 @@
TopoDS_Shape newShape = api_copy.ModifiedShape(*topo_face);
TopoDS_Shape* newShape_ptr = new TopoDS_Shape(newShape);
from_bodies_copy.append(newShape_ptr);
+ is_volume.change_to( CUBIT_FALSE);
}
else if(shell)
{
@@ -1529,6 +1534,7 @@
TopoDS_Shape newShape = api_copy.ModifiedShape(*topo_shell);
TopoDS_Shape* newShape_ptr = new TopoDS_Shape(newShape);
from_bodies_copy.append(newShape_ptr);
+ is_volume.change_to( CUBIT_FALSE);
}
else
{
@@ -1624,11 +1630,40 @@
TopoDS_Shape* tool_shape = tool_bodies_copy.get_and_step();
//bodies overlap, proceed with the subtract
TopoDS_Shape cut_shape = BRepAlgoAPI_Cut(*from_shape, *tool_shape);
- if(!from_shape->Modified())
+
+ //compare to see if the from_shape is getting cut.
+ if(is_volume[i])
{
- count++;
- continue;
+ GProp_GProps myProps;
+ BRepGProp::VolumeProperties(*from_shape, myProps);
+ double orig_mass = myProps.Mass();
+ BRepGProp::VolumeProperties(cut_shape, myProps);
+ double after_mass = myProps.Mass();
+ if((-after_mass + orig_mass) <= tol*tol*tol)
+ {
+ //Add imprint code here
+ if(imprint)
+ imprint_toposhapes(from_shape, tool_shape);
+ count++;
+ continue;
+ }
}
+ else
+ {
+ GProp_GProps myProps;
+ BRepGProp::SurfaceProperties(*from_shape, myProps);
+ double orig_mass = myProps.Mass();
+ BRepGProp::SurfaceProperties(cut_shape, myProps);
+ double after_mass = myProps.Mass();
+ if((-after_mass + orig_mass) <= tol*tol)
+ {
+ //Add imprint code here
+ if(imprint)
+ imprint_toposhapes(from_shape, tool_shape);
+ count++;
+ continue;
+ }
+ }
delete from_shape;
from_shape = new TopoDS_Shape(cut_shape);
}
@@ -1651,7 +1686,7 @@
if ((100 - frac_done) < fraction_remaining)
{
fraction_remaining = 100 - frac_done;
- PRINT_INFO("%d% remaining.\n ", fraction_remaining);
+ PRINT_INFO("%d% remaining.\n ", fraction_remaining+1);
}
}
}
@@ -1677,6 +1712,20 @@
return CUBIT_SUCCESS;
}
+CubitStatus OCCModifyEngine::imprint_toposhapes(TopoDS_Shape*& from_shape,
+ TopoDS_Shape* tool_shape)const
+{
+ TopOpeBRep_ShapeIntersector intersector;
+ intersector.InitIntersection(*from_shape, *tool_shape);
+ TopTools_ListOfShape list_of_edges;
+ for(; intersector.MoreIntersection(); intersector.NextIntersection())
+ {
+ TopoDS_Shape face1 = intersector.ChangeFacesIntersector().Face(1);
+ TopoDS_Shape face2 = intersector.ChangeFacesIntersector().Face(2);
+ BRepAlgoAPI_Section section(face1, face2);
+ list_of_edges.Assign(section.SectionEdges());
+ }
+}
//===============================================================================
// Function : imprint
// Member Type: PUBLIC
Modified: cgm/trunk/geom/OCC/OCCModifyEngine.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.hpp 2008-03-19 19:15:46 UTC (rev 1673)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.hpp 2008-03-20 18:50:32 UTC (rev 1674)
@@ -658,6 +658,8 @@
const TopoDS_Face* make_TopoDS_Face( GeometryType surface_type,
DLIList<DLIList<TopoDS_Edge*>*> topo_edges,
Surface* old_surface_ptr) const;
+
+ CubitStatus imprint_toposhapes(TopoDS_Shape*&, TopoDS_Shape*) const;
private:
} ;
1
0
Author: janehu
Date: 2008-03-19 14:15:46 -0500 (Wed, 19 Mar 2008)
New Revision: 1673
Modified:
cgm/trunk/geom/OCC/OCCModifyEngine.cpp
Log:
Fine tuned subtract function.
Modified: cgm/trunk/geom/OCC/OCCModifyEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-03-18 15:43:32 UTC (rev 1672)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-03-19 19:15:46 UTC (rev 1673)
@@ -1599,8 +1599,9 @@
DLIList<TopologyBridge*> tbs;
for (int i = 0; i < from_bodies_copy.size(); i++)
{
- BodySM* from_body = from_bodies.get_and_step();
+ BodySM* from_body = from_bodies.get();
CubitBox box1 = CAST_TO(from_body, OCCBody)->get_bounding_box();
+ int count = 0; //count for not preforming cut
for(int j = 0; j < tool_body_list.size(); j ++)
{
if (cmi->Interrupt())
@@ -1616,17 +1617,31 @@
}
CubitBox tool_box = *tool_boxes.get_and_step();
if(!tool_box.overlap(tol,box1))
+ {
+ count++;
continue;
-
+ }
TopoDS_Shape* tool_shape = tool_bodies_copy.get_and_step();
//bodies overlap, proceed with the subtract
TopoDS_Shape cut_shape = BRepAlgoAPI_Cut(*from_shape, *tool_shape);
+ if(!from_shape->Modified())
+ {
+ count++;
+ continue;
+ }
delete from_shape;
from_shape = new TopoDS_Shape(cut_shape);
}
//ok, we're done wih all cuts, construct new Body'
- tbs = OCCQueryEngine::instance()->populate_topology_bridge(*from_shape);
+ if (count < tool_body_list.size())
+ tbs += OCCQueryEngine::instance()->populate_topology_bridge(*from_shape);
+ else
+ {
+ PRINT_INFO("The %d body did not change because cutting tools are not interscting with it.\n", i+1);
+ from_bodies.change_to(NULL);
+ }
+ from_bodies.step();
from_shape = from_bodies_copy.step_and_get();
// done with this j iteration; write out count, if necessary
@@ -1636,14 +1651,14 @@
if ((100 - frac_done) < fraction_remaining)
{
fraction_remaining = 100 - frac_done;
- PRINT_INFO("%d% remaining. ", fraction_remaining);
+ PRINT_INFO("%d% remaining.\n ", fraction_remaining);
}
}
}
for (int i = 0; i< tbs.size(); i++)
{
- BodySM* bodysm = CAST_TO(tbs.get(), BodySM);
+ BodySM* bodysm = CAST_TO(tbs.get_and_step(), BodySM);
if (bodysm)
new_bodies.append(bodysm);
}
@@ -1655,6 +1670,7 @@
delete tool_bodies_copy.pop();
if (!keep_old)
{
+ from_bodies.remove_all_with_value(NULL);
OCCQueryEngine::instance()->delete_solid_model_entities(from_bodies);
OCCQueryEngine::instance()->delete_solid_model_entities( tool_body_list);
}
1
0
Author: janehu
Date: 2008-03-17 14:35:18 -0500 (Mon, 17 Mar 2008)
New Revision: 1671
Modified:
cgm/trunk/geom/OCC/OCCModifyEngine.cpp
cgm/trunk/test/modify.cpp
Log:
Added subtract function and tested on it. with imprint not available now, it works fine for simple unit test.
Modified: cgm/trunk/geom/OCC/OCCModifyEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-03-17 17:43:24 UTC (rev 1670)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-03-17 19:35:18 UTC (rev 1671)
@@ -54,6 +54,7 @@
#include "TopoDS.hxx"
#include "TopologyBridge.hpp"
#include "BRepAlgoAPI_Fuse.hxx"
+#include "BRepAlgoAPI_Cut.hxx"
#include "BRepPrimAPI_MakeSphere.hxx"
#include "BRepPrimAPI_MakeBox.hxx"
#include "BRepPrimAPI_MakeWedge.hxx"
@@ -1416,7 +1417,7 @@
//===============================================================================
// Function : stitch_surfs
// Member Type: PUBLIC
-// Description: stitch all surfs and try to make a closed solid out of them.
+// Description: stitch all surfs and try to make a shell body.
// Author : Jane Hu
// Date : 03/08
//===============================================================================
@@ -1493,16 +1494,170 @@
//===============================================================================
// Function : subtract
// Member Type: PUBLIC
-// Description: subtract boolean operation on facet-based bodies
-// Author : John Fowler
-// Date : 10/02
+// Description: subtract boolean operation on OCC-based bodies
+// Author : Jane Hu
+// Date : 03/08
//===============================================================================
CubitStatus OCCModifyEngine::subtract(DLIList<BodySM*> &tool_body_list,
- DLIList<BodySM*> &from_bodies,
- DLIList<BodySM*> &new_bodies,
- bool /*imprint*/,
- bool keep_old) const
+ DLIList<BodySM*> &from_bodies,
+ DLIList<BodySM*> &new_bodies,
+ bool imprint,
+ bool keep_old) const
{
+ //need to implement "imprint" function.
+ // copy the bodies in case subtraction has some errors
+ DLIList<TopoDS_Shape*> tool_bodies_copy;
+ DLIList<TopoDS_Shape*> from_bodies_copy;
+ for (int i = 0; i < from_bodies.size(); i++)
+ {
+ BodySM* body = from_bodies.get_and_step();
+ OCCBody* occ_body = CAST_TO(body, OCCBody);
+ OCCSurface* surface = occ_body->my_sheet_surface();
+ OCCShell* shell = occ_body->shell();
+ if(surface)
+ {
+ TopoDS_Face* topo_face = surface->get_TopoDS_Face();
+ BRepBuilderAPI_Copy api_copy(*topo_face);
+ TopoDS_Shape newShape = api_copy.ModifiedShape(*topo_face);
+ TopoDS_Shape* newShape_ptr = new TopoDS_Shape(newShape);
+ from_bodies_copy.append(newShape_ptr);
+ }
+ else if(shell)
+ {
+ TopoDS_Shell* topo_shell = shell->get_TopoDS_Shell();
+ BRepBuilderAPI_Copy api_copy(*topo_shell);
+ TopoDS_Shape newShape = api_copy.ModifiedShape(*topo_shell);
+ TopoDS_Shape* newShape_ptr = new TopoDS_Shape(newShape);
+ from_bodies_copy.append(newShape_ptr);
+ }
+ else
+ {
+ DLIList<Lump*> lumps = occ_body->lumps();
+ if (lumps.size() > 1)
+ {
+ PRINT_ERROR("Can't do boolean operation on CompSolid types. \n");
+ return CUBIT_FAILURE;
+ }
+
+ TopoDS_Solid* solid = CAST_TO(lumps.get(), OCCLump)->get_TopoDS_Solid();
+ BRepBuilderAPI_Copy api_copy(*solid);
+ TopoDS_Shape newShape = api_copy.ModifiedShape(*solid);
+ TopoDS_Shape* newShape_ptr = new TopoDS_Shape(newShape);
+ from_bodies_copy.append(newShape_ptr);
+ }
+ }
+
+ DLIList<CubitBox*> tool_boxes;
+ for (int i = 0; i < tool_body_list.size(); i++)
+ {
+ BodySM* body = tool_body_list.get_and_step();
+ OCCBody* occ_body = CAST_TO(body, OCCBody);
+ OCCSurface* surface = occ_body->my_sheet_surface();
+ OCCShell* shell = occ_body->shell();
+ if(surface)
+ {
+ TopoDS_Face* topo_face = surface->get_TopoDS_Face();
+ BRepBuilderAPI_Copy api_copy(*topo_face);
+ TopoDS_Shape newShape = api_copy.ModifiedShape(*topo_face);
+ TopoDS_Shape* newShape_ptr = new TopoDS_Shape(newShape);
+ tool_bodies_copy.append(newShape_ptr);
+ }
+ else if(shell)
+ {
+ TopoDS_Shell* topo_shell = shell->get_TopoDS_Shell();
+ BRepBuilderAPI_Copy api_copy(*topo_shell);
+ TopoDS_Shape newShape = api_copy.ModifiedShape(*topo_shell);
+ TopoDS_Shape* newShape_ptr = new TopoDS_Shape(newShape);
+ tool_bodies_copy.append(newShape_ptr);
+ }
+ else
+ {
+ DLIList<Lump*> lumps = occ_body->lumps();
+ if (lumps.size() > 1)
+ {
+ PRINT_ERROR("Can't do boolean operation on CompSolid types. \n");
+ return CUBIT_FAILURE;
+ }
+
+ TopoDS_Solid* solid = CAST_TO(lumps.get(), OCCLump)->get_TopoDS_Solid();
+ BRepBuilderAPI_Copy api_copy(*solid);
+ TopoDS_Shape newShape = api_copy.ModifiedShape(*solid);
+ TopoDS_Shape* newShape_ptr = new TopoDS_Shape(newShape);
+ tool_bodies_copy.append(newShape_ptr);
+ }
+ CubitBox *tool_box = new CubitBox(occ_body->get_bounding_box());
+ tool_boxes.append(tool_box);
+ }
+
+ double tol = OCCQueryEngine::instance()->get_sme_resabs_tolerance();
+ int fraction_remaining = 100;
+
+ // subtract the tool body from each body in the list
+
+ CubitMessage* cmi = CubitMessage::instance();
+ TopoDS_Shape* from_shape = from_bodies_copy.get();
+ DLIList<TopologyBridge*> tbs;
+ for (int i = 0; i < from_bodies_copy.size(); i++)
+ {
+ BodySM* from_body = from_bodies.get_and_step();
+ CubitBox box1 = CAST_TO(from_body, OCCBody)->get_bounding_box();
+ for(int j = 0; j < tool_body_list.size(); j ++)
+ {
+ if (cmi->Interrupt())
+ {
+ PRINT_ERROR("Subtraction interrupted. Aborting...\n");
+ while (tool_boxes.size())
+ delete tool_boxes.pop();
+ while (tool_bodies_copy.size())
+ delete tool_bodies_copy.pop();
+ while (from_bodies_copy.size())
+ delete from_bodies_copy.pop();
+ return CUBIT_FAILURE;
+ }
+ CubitBox tool_box = *tool_boxes.get_and_step();
+ if(!tool_box.overlap(tol,box1))
+ continue;
+
+ TopoDS_Shape* tool_shape = tool_bodies_copy.get_and_step();
+ //bodies overlap, proceed with the subtract
+ TopoDS_Shape cut_shape = BRepAlgoAPI_Cut(*from_shape, *tool_shape);
+ delete from_shape;
+ from_shape = new TopoDS_Shape(cut_shape);
+ }
+
+ //ok, we're done wih all cuts, construct new Body'
+ tbs = OCCQueryEngine::instance()->populate_topology_bridge(*from_shape);
+ from_shape = from_bodies_copy.step_and_get();
+
+ // done with this j iteration; write out count, if necessary
+ if (from_bodies.size() * tool_body_list.size() > 1)
+ {
+ int frac_done = (100 * (i+1)) / (from_bodies.size());
+ if ((100 - frac_done) < fraction_remaining)
+ {
+ fraction_remaining = 100 - frac_done;
+ PRINT_INFO("%d% remaining. ", fraction_remaining);
+ }
+ }
+ }
+
+ for (int i = 0; i< tbs.size(); i++)
+ {
+ BodySM* bodysm = CAST_TO(tbs.get(), BodySM);
+ if (bodysm)
+ new_bodies.append(bodysm);
+ }
+
+ //ok, we're done wih all cuts, construct new Body's
+ while (tool_boxes.size())
+ delete tool_boxes.pop();
+ while (tool_bodies_copy.size())
+ delete tool_bodies_copy.pop();
+ if (!keep_old)
+ {
+ OCCQueryEngine::instance()->delete_solid_model_entities(from_bodies);
+ OCCQueryEngine::instance()->delete_solid_model_entities( tool_body_list);
+ }
return CUBIT_SUCCESS;
}
Modified: cgm/trunk/test/modify.cpp
===================================================================
--- cgm/trunk/test/modify.cpp 2008-03-17 17:43:24 UTC (rev 1670)
+++ cgm/trunk/test/modify.cpp 2008-03-17 19:35:18 UTC (rev 1671)
@@ -174,5 +174,23 @@
free_entities.clean_out();
gti->bodies(bodies);
gti->get_free_ref_entities(free_entities);
+
+ //delete all entities
+ gti->delete_Body(bodies);
+
+ for (int j = free_entities.size(); j--;)
+ {
+ gti->delete_RefEntity( free_entities.get_and_step());
+ }
+
+ //test for subtract
+ Body* from_body = gmti->brick(10, 10, 10);
+ Body* tool_body = gmti->brick(1, 1, 1);
+ DLIList<Body*> from_bodies;
+ from_bodies.append(from_body);
+ DLIList<Body*> new_bodies;
+ rsl = gmti->subtract(tool_body, from_bodies, new_bodies,
+ CUBIT_FALSE, CUBIT_FALSE);
+ double d = new_bodies.get()->measure();
return stat;
}
1
0
Author: janehu
Date: 2008-03-13 14:31:27 -0500 (Thu, 13 Mar 2008)
New Revision: 1649
Modified:
cgm/trunk/geom/OCC/OCCBody.cpp
cgm/trunk/geom/OCC/OCCModifyEngine.cpp
cgm/trunk/geom/OCC/OCCQueryEngine.cpp
cgm/trunk/geom/OCC/OCCShell.cpp
cgm/trunk/geom/OCC/OCCSurface.cpp
cgm/trunk/test/Makefile.am
cgm/trunk/test/modify.cpp
Log:
Modified model import/export code to work with shell bodies,standalone surfaces and shells are all in bodySM's. Added tests on these and stitch surfs now working too.
Modified: cgm/trunk/geom/OCC/OCCBody.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCBody.cpp 2008-03-13 19:27:31 UTC (rev 1648)
+++ cgm/trunk/geom/OCC/OCCBody.cpp 2008-03-13 19:31:27 UTC (rev 1649)
@@ -88,6 +88,7 @@
}
myTopoDSShape = new TopoDS_CompSolid(Co);
IsSheetBody = CUBIT_FALSE;
+ myShell = NULL;
update_bounding_box();
}
Modified: cgm/trunk/geom/OCC/OCCModifyEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-03-13 19:27:31 UTC (rev 1648)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-03-13 19:31:27 UTC (rev 1649)
@@ -1487,8 +1487,6 @@
stitched_body = face->my_body();
}
- //delete all original surfaces
- OCCQueryEngine::instance()->delete_solid_model_entities(surf_bodies);
return CUBIT_SUCCESS;
}
Modified: cgm/trunk/geom/OCC/OCCQueryEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCQueryEngine.cpp 2008-03-13 19:27:31 UTC (rev 1648)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.cpp 2008-03-13 19:31:27 UTC (rev 1649)
@@ -1082,7 +1082,12 @@
}
for (Ex.Init(aShape, TopAbs_FACE, TopAbs_SHELL); Ex.More(); Ex.Next())
- tblist.append(populate_topology_bridge(TopoDS::Face(Ex.Current()),CUBIT_TRUE));
+ {
+ Surface* face =
+ populate_topology_bridge(TopoDS::Face(Ex.Current()),CUBIT_TRUE);
+ if(face)
+ tblist.append(CAST_TO(face, OCCSurface)->my_body());
+ }
for (Ex.Init(aShape, TopAbs_WIRE, TopAbs_FACE); Ex.More(); Ex.Next())
populate_topology_bridge(TopoDS::Wire(Ex.Current()), CUBIT_TRUE);
@@ -1092,6 +1097,7 @@
for (Ex.Init(aShape, TopAbs_VERTEX, TopAbs_EDGE); Ex.More(); Ex.Next())
tblist.append(populate_topology_bridge(TopoDS::Vertex(Ex.Current())));
+ tblist.remove_all_with_value(NULL);
return tblist;
}
@@ -1110,21 +1116,22 @@
OccToCGM->insert(valType(iTotalTBCreated,
(TopologyBridge*)body));
BodyList->append(body);
+
+ TopExp_Explorer Ex;
+ DLIList<Lump*> lumps;
+ for (Ex.Init(aShape, TopAbs_SOLID); Ex.More(); Ex.Next())
+ {
+ Lump* lump = populate_topology_bridge(TopoDS::Solid(Ex.Current()));
+ lumps.append(lump);
+ CAST_TO(lump, OCCLump)->add_body(body);
+ }
+ body->lumps(lumps);
}
else
{
int k = OCCMap->Find(*posolid);
body = (OCCBody*)(OccToCGM->find(k))->second;
}
- TopExp_Explorer Ex;
- DLIList<Lump*> lumps;
- for (Ex.Init(aShape, TopAbs_SOLID); Ex.More(); Ex.Next())
- {
- Lump* lump = populate_topology_bridge(TopoDS::Solid(Ex.Current()));
- lumps.append(lump);
- CAST_TO(lump, OCCLump)->add_body(body);
- }
- body->lumps(lumps);
return body;
}
@@ -1137,31 +1144,32 @@
OCCLump *lump;
OCCBody *body;
if (!OCCMap->IsBound(*posolid))
+ {
+ if(PRINT_RESULT)
+ PRINT_INFO("Adding solids.\n");
+ iTotalTBCreated++;
+ lump = new OCCLump(posolid);
+ if (build_body)
{
- if(PRINT_RESULT)
- PRINT_INFO("Adding solids.\n");
- iTotalTBCreated++;
- lump = new OCCLump(posolid);
- if (build_body)
- {
- DLIList<Lump*> lumps;
- lumps.append(lump);
- body = new OCCBody(lumps);
- BodyList->append(body);
- lump->add_body(body);
- }
- OCCMap->Bind(*posolid, iTotalTBCreated);
- OccToCGM->insert(valType(iTotalTBCreated,
- (TopologyBridge*)lump));
+ DLIList<Lump*> lumps;
+ lumps.append(lump);
+ body = new OCCBody(lumps);
+ BodyList->append(body);
+ lump->add_body(body);
}
+ OCCMap->Bind(*posolid, iTotalTBCreated);
+ OccToCGM->insert(valType(iTotalTBCreated,
+ (TopologyBridge*)lump));
+
+ TopExp_Explorer Ex;
+ for (Ex.Init(aShape, TopAbs_SHELL); Ex.More(); Ex.Next())
+ populate_topology_bridge(TopoDS::Shell(Ex.Current()));
+ }
else
- {
- int k = OCCMap->Find(*posolid);
- lump = (OCCLump*)(OccToCGM->find(k))->second;
- }
- TopExp_Explorer Ex;
- for (Ex.Init(aShape, TopAbs_SHELL); Ex.More(); Ex.Next())
- populate_topology_bridge(TopoDS::Shell(Ex.Current()));
+ {
+ int k = OCCMap->Find(*posolid);
+ lump = (OCCLump*)(OccToCGM->find(k))->second;
+ }
return lump;
}
@@ -1173,31 +1181,39 @@
OCCShell *shell ;
CubitBoolean build_body = CUBIT_FALSE;
if (!OCCMap->IsBound(*poshell))
+ {
+ if(PRINT_RESULT)
+ PRINT_INFO("Adding shells.\n");
+ iTotalTBCreated++;
+ shell = new OCCShell(poshell);
+ OCCMap->Bind(*poshell, iTotalTBCreated);
+ OccToCGM->insert(valType(iTotalTBCreated,
+ (TopologyBridge*)shell));
+
+ if(standalone)
{
- if(PRINT_RESULT)
- PRINT_INFO("Adding shells.\n");
- iTotalTBCreated++;
- shell = new OCCShell(poshell);
- OCCMap->Bind(*poshell, iTotalTBCreated);
- OccToCGM->insert(valType(iTotalTBCreated,
- (TopologyBridge*)shell));
+ OCCLump* lump = new OCCLump(NULL, NULL, shell);
+ OCCBody* body = new OCCBody(NULL, CUBIT_FALSE, NULL, shell);
+ shell->set_body(body);
+ shell->set_lump(lump);
+ //don't need to add body into BodyList.
+ }
+
+ TopExp_Explorer Ex;
+ for (Ex.Init(aShape, TopAbs_FACE); Ex.More(); Ex.Next())
+ {
+ Surface* face =
+ populate_topology_bridge(TopoDS::Face(Ex.Current()), build_body);
if(standalone)
- {
- OCCLump* lump = new OCCLump(NULL, NULL, shell);
- OCCBody* body = new OCCBody(NULL, CUBIT_FALSE, NULL, shell);
- shell->set_body(body);
- shell->set_lump(lump);
- }
+ CAST_TO(face,OCCSurface)->set_shell(shell);
}
+ }
else
- {
- int k = OCCMap->Find(*poshell);
- shell = (OCCShell*)(OccToCGM->find(k))->second;
- }
+ {
+ int k = OCCMap->Find(*poshell);
+ shell = (OCCShell*)(OccToCGM->find(k))->second;
+ }
- TopExp_Explorer Ex;
- for (Ex.Init(aShape, TopAbs_FACE); Ex.More(); Ex.Next())
- populate_topology_bridge(TopoDS::Face(Ex.Current()), build_body);
return shell;
}
@@ -1206,38 +1222,38 @@
{
TopoDS_Face *poface = new TopoDS_Face;
*poface = aShape;
- OCCSurface *surface;
+ OCCSurface *surface = NULL;
if (!OCCMap->IsBound(*poface))
- {
- surface = new OCCSurface(poface);
+ {
+ surface = new OCCSurface(poface);
- if(PRINT_RESULT)
- PRINT_INFO("Adding faces.\n");
- iTotalTBCreated++;
- OCCMap->Bind(*poface, iTotalTBCreated);
- OccToCGM->insert(valType(iTotalTBCreated,
+ if(PRINT_RESULT)
+ PRINT_INFO("Adding faces.\n");
+ iTotalTBCreated++;
+ OCCMap->Bind(*poface, iTotalTBCreated);
+ OccToCGM->insert(valType(iTotalTBCreated,
(TopologyBridge*)surface));
- SurfaceList->append(surface);
- }
- else
+ SurfaceList->append(surface);
+ if(build_body)
{
- int k = OCCMap->Find(*poface);
- surface = (OCCSurface*)(OccToCGM->find(k))->second;
- }
-
- if(build_body)
- {
OCCShell* shell = new OCCShell(NULL, surface);
OCCLump* lump = new OCCLump(NULL, surface);
OCCBody* body = new OCCBody(NULL, CUBIT_TRUE, surface);
surface->set_body(body);
surface->set_lump(lump);
surface->set_shell(shell);
+ //Doesn't need to save sheet bodies.
}
+ TopExp_Explorer Ex;
+ for (Ex.Init(aShape, TopAbs_WIRE); Ex.More(); Ex.Next())
+ populate_topology_bridge(TopoDS::Wire(Ex.Current()));
+ }
- TopExp_Explorer Ex;
- for (Ex.Init(aShape, TopAbs_WIRE); Ex.More(); Ex.Next())
- populate_topology_bridge(TopoDS::Wire(Ex.Current()));
+ else
+ {
+ int k = OCCMap->Find(*poface);
+ surface = (OCCSurface*)(OccToCGM->find(k))->second;
+ }
return surface;
}
@@ -1259,6 +1275,19 @@
(TopologyBridge*)loop));
if(standalone)
WireList->append(loop);
+
+ BRepTools_WireExplorer Ex;
+ DLIList <OCCCoEdge*> coedges;
+ for (Ex.Init(aShape); Ex.More(); Ex.Next())
+ {
+ Curve* curve = populate_topology_bridge(Ex.Current());
+ OCCCurve *occ_curve = CAST_TO(curve, OCCCurve);
+ OCCCoEdge * coedge = new OCCCoEdge( curve, loop,
+ (Ex.Orientation() == TopAbs_FORWARD ? CUBIT_FORWARD : CUBIT_REVERSED));
+ coedges.append(coedge);
+ occ_curve->add_loop(loop);
+ }
+ loop->coedges(coedges);
}
else
{
@@ -1266,19 +1295,6 @@
loop = (OCCLoop*)(OccToCGM->find(k))->second;
}
- BRepTools_WireExplorer Ex;
- DLIList <OCCCoEdge*> coedges;
- for (Ex.Init(aShape); Ex.More(); Ex.Next())
- {
- Curve* curve = populate_topology_bridge(Ex.Current());
- OCCCurve *occ_curve = CAST_TO(curve, OCCCurve);
- OCCCoEdge * coedge = new OCCCoEdge( curve, loop,
- (Ex.Orientation()== TopAbs_FORWARD ? CUBIT_FORWARD : CUBIT_REVERSED));
- coedges.append(coedge);
- occ_curve->add_loop(loop);
- }
- loop->coedges(coedges);
-
return loop;
}
@@ -1297,6 +1313,10 @@
OccToCGM->insert(valType(iTotalTBCreated,
(TopologyBridge*)curve));
CurveList->append((OCCCurve*)curve);
+
+ TopExp_Explorer Ex;
+ for (Ex.Init(aShape, TopAbs_VERTEX); Ex.More(); Ex.Next())
+ populate_topology_bridge(TopoDS::Vertex(Ex.Current()));
}
else
{
@@ -1304,9 +1324,6 @@
curve = (OCCCurve*)(OccToCGM->find(i))->second;
}
- TopExp_Explorer Ex;
- for (Ex.Init(aShape, TopAbs_VERTEX); Ex.More(); Ex.Next())
- populate_topology_bridge(TopoDS::Vertex(Ex.Current()));
return curve;
}
Modified: cgm/trunk/geom/OCC/OCCShell.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCShell.cpp 2008-03-13 19:27:31 UTC (rev 1648)
+++ cgm/trunk/geom/OCC/OCCShell.cpp 2008-03-13 19:31:27 UTC (rev 1649)
@@ -110,7 +110,7 @@
{
if(mySheetSurface)
{
- parents.append(mySheetSurface->my_lump());
+ parents.append(mySheetSurface->my_body());
return;
}
Modified: cgm/trunk/geom/OCC/OCCSurface.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCSurface.cpp 2008-03-13 19:27:31 UTC (rev 1648)
+++ cgm/trunk/geom/OCC/OCCSurface.cpp 2008-03-13 19:31:27 UTC (rev 1649)
@@ -676,6 +676,12 @@
return;
}
+ if(myShell) //shell body
+ {
+ parents.append(myShell);
+ return;
+ }
+
OCCQueryEngine* oqe = (OCCQueryEngine*) get_geometry_query_engine();
OCCBody * body = NULL;
DLIList <OCCBody* > *bodies = oqe->BodyList;
Modified: cgm/trunk/test/Makefile.am
===================================================================
--- cgm/trunk/test/Makefile.am 2008-03-13 19:27:31 UTC (rev 1648)
+++ cgm/trunk/test/Makefile.am 2008-03-13 19:31:27 UTC (rev 1649)
@@ -35,4 +35,5 @@
webcut_LDADD = ../geom/ACIS/libcubit_ACIS.la $(LDADD)
makept_LDFLAGS = $(LDFLAGS) -R$(OCC_LIB_DIR)
makept_LDADD = ../geom/OCC/libcubit_OCC.la $(LDADD)
-
+modify_LDFLAGS = $(LDFLAGS) -R$(OCC_LIB_DIR)
+modify_LDADD = ../geom/OCC/libcubit_OCC.la $(LDADD)
Modified: cgm/trunk/test/modify.cpp
===================================================================
--- cgm/trunk/test/modify.cpp 2008-03-13 19:27:31 UTC (rev 1648)
+++ cgm/trunk/test/modify.cpp 2008-03-13 19:31:27 UTC (rev 1649)
@@ -143,6 +143,16 @@
CubitVector v = body2->center_point();
+ CubitStatus rsl = CUBIT_SUCCESS;
+ DLIList<RefEntity*> ref_entity_list;
+ int num_ents_exported=0;
+ const CubitString cubit_version="10.2";
+ const char * filename = "stitch.occ";
+ const char * filetype = "OCC";
+
+ rsl = gti->export_solid_model(ref_entity_list, filename, filetype,
+ num_ents_exported, cubit_version);
+
DLIList<Body*> bodies;
DLIList<RefEntity*> free_entities;
gti->bodies(bodies);
@@ -155,5 +165,14 @@
gti->delete_RefEntity( free_entities.get_and_step());
}
+ // Read in the geometry from files specified on the command line
+ char *argv = "./stitch.occ";
+ CubitStatus status = read_geometry(1, &argv);
+ if (status == CUBIT_FAILURE) exit(1);
+
+ bodies.clean_out();
+ free_entities.clean_out();
+ gti->bodies(bodies);
+ gti->get_free_ref_entities(free_entities);
return stat;
}
1
0
Author: janehu
Date: 2008-03-12 13:45:10 -0500 (Wed, 12 Mar 2008)
New Revision: 1643
Modified:
cgm/trunk/geom/OCC/OCCBody.cpp
cgm/trunk/geom/OCC/OCCBody.hpp
cgm/trunk/geom/OCC/OCCLump.cpp
cgm/trunk/geom/OCC/OCCLump.hpp
cgm/trunk/geom/OCC/OCCModifyEngine.cpp
cgm/trunk/geom/OCC/OCCQueryEngine.cpp
cgm/trunk/geom/OCC/OCCQueryEngine.hpp
cgm/trunk/geom/OCC/OCCShell.hpp
Log:
Added shell body for stitch operation, still has problems dealing with existing surfaces used for stitching, working on that.
Modified: cgm/trunk/geom/OCC/OCCBody.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCBody.cpp 2008-03-12 18:04:16 UTC (rev 1642)
+++ cgm/trunk/geom/OCC/OCCBody.cpp 2008-03-12 18:45:10 UTC (rev 1643)
@@ -60,11 +60,12 @@
//
//-------------------------------------------------------------------------
OCCBody::OCCBody(TopoDS_CompSolid *theShape, CubitBoolean isSheetBody,
- OCCSurface* surface)
+ OCCSurface* surface, OCCShell* shell)
{
myTopoDSShape = theShape;
IsSheetBody = isSheetBody;
mySheetSurface = surface;
+ myShell = shell;
update_bounding_box();
}
@@ -157,6 +158,12 @@
aBRepTrsf.Perform(*face);
OCCQueryEngine::instance()->update_entity_shape(mySheetSurface, aBRepTrsf);
}
+ else if(myShell)
+ {
+ TopoDS_Shell* shell = myShell->get_TopoDS_Shell();
+ aBRepTrsf.Perform(*shell);
+ myShell->update_OCC_entity(aBRepTrsf);
+ }
else
{
aBRepTrsf.Perform(*myTopoDSShape);
@@ -194,6 +201,12 @@
aBRepTrsf.Perform(*face);
OCCQueryEngine::instance()->update_entity_shape(mySheetSurface, aBRepTrsf);
}
+ else if(myShell)
+ {
+ TopoDS_Shell* shell = myShell->get_TopoDS_Shell();
+ aBRepTrsf.Perform(*shell);
+ myShell->update_OCC_entity(aBRepTrsf);
+ }
else
{
aBRepTrsf.Perform(*myTopoDSShape);
@@ -225,6 +238,12 @@
aBRepTrsf.Perform(*face);
OCCQueryEngine::instance()->update_entity_shape(mySheetSurface, aBRepTrsf);
}
+ else if(myShell)
+ {
+ TopoDS_Shell* shell = myShell->get_TopoDS_Shell();
+ aBRepTrsf.Perform(*shell);
+ myShell->update_OCC_entity(aBRepTrsf);
+ }
else
{
aBRepTrsf.Perform(*myTopoDSShape);
@@ -276,6 +295,12 @@
aBRepTrsf.Perform(*face);
OCCQueryEngine::instance()->update_entity_shape(mySheetSurface, aBRepTrsf);
}
+ else if(myShell)
+ {
+ TopoDS_Shell* shell = myShell->get_TopoDS_Shell();
+ aBRepTrsf.Perform(*shell);
+ myShell->update_OCC_entity(aBRepTrsf);
+ }
else
{
aBRepTrsf.Perform(*myTopoDSShape);
@@ -296,7 +321,7 @@
//----------------------------------------------------------------
CubitStatus OCCBody::update_OCC_entity( BRepBuilderAPI_Transform &aBRepTrsf)
{
- if(IsSheetBody)
+ if(IsSheetBody || myShell)
return CUBIT_FAILURE;
TopoDS_Shape shape = aBRepTrsf.Shape();
@@ -347,6 +372,8 @@
TopoDS_Shape shape;
if(IsSheetBody)
shape = *(mySheetSurface->get_TopoDS_Face());
+ else if(myShell)
+ shape = *(myShell->get_TopoDS_Shell());
else
shape=*myTopoDSShape;
@@ -383,6 +410,12 @@
return;
}
+ if (myShell)
+ {
+ lumps.append(myShell->my_lump());
+ return;
+ }
+
TopTools_IndexedMapOfShape M;
TopExp::MapShapes(*myTopoDSShape, TopAbs_SOLID, M);
int ii;
@@ -405,7 +438,7 @@
CubitStatus OCCBody::mass_properties( CubitVector& centroid,
double& volume )
{
- if(IsSheetBody)
+ if(IsSheetBody || myShell)
return CUBIT_FAILURE;
GProp_GProps myProps;
BRepGProp::VolumeProperties(*myTopoDSShape, myProps);
@@ -427,7 +460,7 @@
//-------------------------------------------------------------------------
CubitPointContainment OCCBody::point_containment( const CubitVector &point )
{
- if(IsSheetBody)
+ if(IsSheetBody || myShell)
return CUBIT_PNT_UNKNOWN;
CubitPointContainment pc_value;
@@ -464,8 +497,14 @@
surfaces.append(mySheetSurface);
return;
}
+
+ TopoDS_Shape shape;
+ if (myShell)
+ shape = *(myShell->get_TopoDS_Shell());
+ else
+ shape = *myTopoDSShape;
TopTools_IndexedMapOfShape M;
- TopExp::MapShapes(*myTopoDSShape, TopAbs_FACE, M);
+ TopExp::MapShapes(shape, TopAbs_FACE, M);
int ii;
for (ii=1; ii<=M.Extent(); ii++) {
TopologyBridge *surface = OCCQueryEngine::instance()->occ_to_cgm(M(ii));
@@ -490,6 +529,8 @@
TopoDS_Shape shape;
if(IsSheetBody)
shape = *(mySheetSurface->get_TopoDS_Face());
+ else if(myShell)
+ shape = *(myShell->get_TopoDS_Shell());
else
shape = *myTopoDSShape;
@@ -519,6 +560,8 @@
TopoDS_Shape shape;
if(IsSheetBody)
shape = *(mySheetSurface->get_TopoDS_Face());
+ else if(myShell)
+ shape = *(myShell->get_TopoDS_Shell());
else
shape = *myTopoDSShape;
Modified: cgm/trunk/geom/OCC/OCCBody.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCBody.hpp 2008-03-12 18:04:16 UTC (rev 1642)
+++ cgm/trunk/geom/OCC/OCCBody.hpp 2008-03-12 18:45:10 UTC (rev 1643)
@@ -47,11 +47,14 @@
public:
OCCBody(TopoDS_CompSolid *theShape, CubitBoolean isSheetBody = CUBIT_FALSE,
- OCCSurface* surface = NULL);
+ OCCSurface* surface = NULL, OCCShell* shell = NULL);
OCCBody(DLIList<Lump*>& my_lumps);
void lumps(DLIList<Lump*>& my_lumps); //add lump list to myLumps
DLIList<Lump*> lumps(){return myLumps;}
+
+ void shell(OCCShell* shell) {myShell = shell;}
+ OCCShell* shell() {return myShell;}
virtual ~OCCBody() ;
//- The destructor.
@@ -190,7 +193,9 @@
CubitBoolean IsSheetBody;
- OCCSurface* mySheetSurface;
+ OCCSurface* mySheetSurface; //one surface body
+
+ OCCShell* myShell; //shell only body
};
Modified: cgm/trunk/geom/OCC/OCCLump.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCLump.cpp 2008-03-12 18:04:16 UTC (rev 1642)
+++ cgm/trunk/geom/OCC/OCCLump.cpp 2008-03-12 18:45:10 UTC (rev 1643)
@@ -64,10 +64,11 @@
// Special Notes :
//
//-------------------------------------------------------------------------
-OCCLump::OCCLump(TopoDS_Solid *theSolid, OCCSurface* surface)
+OCCLump::OCCLump(TopoDS_Solid *theSolid, OCCSurface* surface, OCCShell* shell)
{
myTopoDSSolid = theSolid;
mySheetSurface = surface;
+ myShell = shell;
}
OCCLump::~OCCLump()
@@ -85,7 +86,7 @@
CubitStatus OCCLump::mass_properties( CubitVector& centroid,
double& volume )
{
- if (mySheetSurface)
+ if (mySheetSurface || myShell)
return CUBIT_FAILURE;
GProp_GProps myProps;
@@ -177,6 +178,8 @@
TopoDS_Shape shape;
if(mySheetSurface)
shape = *(mySheetSurface->get_TopoDS_Face());
+ else if(myShell)
+ shape = *(myShell->get_TopoDS_Shell());
else
shape =*myTopoDSSolid;
@@ -215,7 +218,7 @@
//-------------------------------------------------------------------------
double OCCLump::measure()
{
- if(mySheetSurface)
+ if(mySheetSurface || myShell)
return 0.0;
GProp_GProps myProps;
BRepGProp::VolumeProperties(*myTopoDSSolid, myProps);
@@ -226,6 +229,8 @@
{
if(mySheetSurface)
bodies.append(mySheetSurface->my_body());
+ else if (myShell)
+ bodies.append(myShell->my_body());
else
bodies.append(myBodyPtr);
}
@@ -237,6 +242,11 @@
shellsms.append(mySheetSurface->my_shell());
return;
}
+ else if(myShell)
+ {
+ shellsms.append(myShell);
+ return;
+ }
TopTools_IndexedMapOfShape M;
TopExp::MapShapes(*myTopoDSSolid, TopAbs_SHELL, M);
int ii;
@@ -250,7 +260,7 @@
CubitPointContainment OCCLump::point_containment( const CubitVector &point )
{
- if (mySheetSurface)
+ if (mySheetSurface || myShell)
return CUBIT_PNT_UNKNOWN;
BOP_SolidClassifier ps;
@@ -283,7 +293,7 @@
//----------------------------------------------------------------
CubitStatus OCCLump::update_OCC_entity( BRepBuilderAPI_Transform &aBRepTrsf)
{
- if(mySheetSurface)
+ if(mySheetSurface || myShell)
return CUBIT_FAILURE;
TopoDS_Shape shape = aBRepTrsf.ModifiedShape(*get_TopoDS_Solid());
Modified: cgm/trunk/geom/OCC/OCCLump.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCLump.hpp 2008-03-12 18:04:16 UTC (rev 1642)
+++ cgm/trunk/geom/OCC/OCCLump.hpp 2008-03-12 18:45:10 UTC (rev 1643)
@@ -44,7 +44,8 @@
{
public:
- OCCLump(TopoDS_Solid *theSolid, OCCSurface* surface = NULL);
+ OCCLump(TopoDS_Solid *theSolid, OCCSurface* surface = NULL,
+ OCCShell* shell = NULL);
virtual ~OCCLump();
//- The destructor
@@ -161,6 +162,7 @@
//List of OCCAttrib*'s instead of CubitSimpleAttribs
OCCSurface *mySheetSurface;
+ OCCShell * myShell;
} ;
Modified: cgm/trunk/geom/OCC/OCCModifyEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-03-12 18:04:16 UTC (rev 1642)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-03-12 18:45:10 UTC (rev 1643)
@@ -45,6 +45,7 @@
#include "BRepBuilderAPI_MakeEdge.hxx"
#include "BRepAdaptor_Surface.hxx"
#include "BRepBuilderAPI_MakeFace.hxx"
+#include "BRepBuilderAPI_Sewing.hxx"
#include "BRepBuilderAPI_Copy.hxx"
#include "BRep_Tool.hxx"
#include "BRep_Builder.hxx"
@@ -1415,7 +1416,7 @@
//===============================================================================
// Function : stitch_surfs
// Member Type: PUBLIC
-// Description: Unite surfs into one surface sheet body
+// Description: stitch all surfs and try to make a closed solid out of them.
// Author : Jane Hu
// Date : 03/08
//===============================================================================
@@ -1436,7 +1437,7 @@
DLIList<TopoDS_Face*> faces_to_stitch;
for (int i = 0; i < surf_bodies.size(); i++)
{
- BodySM * tool_body = surf_bodies.get();
+ BodySM * tool_body = surf_bodies.get_and_step();
OCCBody* occ_body = CAST_TO(tool_body, OCCBody);
OCCSurface* surface = occ_body->my_sheet_surface();
if (surface == NULL)
@@ -1449,58 +1450,43 @@
faces_to_stitch.append(topods_face);
}
- TopoDS_Face* first_face = faces_to_stitch.get();
+ TopoDS_Shape* first_face = faces_to_stitch.get();
TopoDS_Face* second_face = NULL;
- TopoDS_Face* new_face = NULL ;
- CubitBoolean disconnected = CUBIT_FALSE;
- TopoDS_Shape fusion;
- int count = 0;
- for(int i = 0; i < faces_to_stitch.size(); i++)
+ TopoDS_Shape fuse;
+ for(int i = 1; i < faces_to_stitch.size(); i++)
{
- if (count > 0)
- first_face = new_face;
-
- for(int j = i + 1; j < faces_to_stitch.size(); j++)
- {
- second_face = faces_to_stitch[j];
- BRepAlgoAPI_Fuse fuse(*first_face, *second_face);
- if (fuse.ErrorStatus() != 0 && fuse.ErrorStatus() != 1)
- {
- PRINT_ERROR("Can't operate fusion for given surfaces. \n");
- return CUBIT_FAILURE;
- }
- else if (fuse.ErrorStatus() == 1)
- {
- //The Object is created but Nothing is Done
- disconnected = CUBIT_TRUE;
- continue;
- }
+ second_face = faces_to_stitch[i];
+ fuse = BRepAlgoAPI_Fuse(*first_face, *second_face);
+ first_face = &fuse;
+ }
- //fused into one face
- fusion = fuse.Shape1();
- if (count > 0)
- delete new_face;
- new_face = new TopoDS_Face(TopoDS::Face(fusion));
- faces_to_stitch.remove(second_face);
- disconnected = CUBIT_FALSE;
- i--;
- count++;
- break;
- }
- if (disconnected)
- {
- //Can't make a body out of disconnected faces
- PRINT_ERROR("Can't create one BodySM out of disconnected surfaces. \n");
- if(new_face != NULL)
- delete new_face;
- return CUBIT_FAILURE;
- }
+ TopExp_Explorer Ex;
+ int count_face = 0;
+ int count_shell = 0;
+ for (Ex.Init(fuse, TopAbs_FACE, TopAbs_SHELL); Ex.More(); Ex.Next())
+ count_face++;
+ for (Ex.Init(fuse, TopAbs_SHELL, TopAbs_SOLID); Ex.More(); Ex.Next())
+ count_shell++;
+
+ if (count_face != 1 && count_shell != 1)
+ {
+ PRINT_ERROR("Can't stitch all surfaces into one BodySM's. \n");
+ return CUBIT_FAILURE;
}
+
+ DLIList<TopologyBridge*> tbs = OCCQueryEngine::instance()->
+ populate_topology_bridge(fuse);
+ OCCBody* body = CAST_TO(tbs.get(), OCCBody);
+ if (body)
+ stitched_body = body ;
- Surface* surface = OCCQueryEngine::instance()->
- populate_topology_bridge(*new_face, CUBIT_TRUE);
+ else
+ {
+ OCCSurface* face = CAST_TO(tbs.get(), OCCSurface);
+ if(face)
+ stitched_body = face->my_body();
+ }
- stitched_body = CAST_TO(surface, OCCSurface)->my_body();
//delete all original surfaces
OCCQueryEngine::instance()->delete_solid_model_entities(surf_bodies);
return CUBIT_SUCCESS;
Modified: cgm/trunk/geom/OCC/OCCQueryEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCQueryEngine.cpp 2008-03-12 18:04:16 UTC (rev 1642)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.cpp 2008-03-12 18:45:10 UTC (rev 1643)
@@ -141,7 +141,6 @@
OccToCGM = new std::map<int, TopologyBridge*>;
BodyList = new DLIList<OCCBody*>;
- ShellList = new DLIList<OCCShell*>;
WireList = new DLIList<OCCLoop*>;
SurfaceList = new DLIList<OCCSurface*>;
CurveList = new DLIList<OCCCurve*>;
@@ -158,7 +157,6 @@
delete OCCMap;
delete OccToCGM;
while( BodyList->size() ) delete BodyList->pop();
- delete[] ShellList;
delete[] WireList;
delete[] SurfaceList;
delete[] CurveList;
@@ -939,15 +937,20 @@
OCCBody* body = OCC_bodies.get_and_step();
TopoDS_CompSolid *shape = body->get_TopoDS_Shape();
- if (shape == NULL) //sheet body
+ if (shape == NULL) //sheet body or shell body
{
OCCSurface* surface = body->my_sheet_surface();
- if (surface == NULL)
+ OCCShell* shell = body->shell();
+ if (surface == NULL && shell == NULL)
{
+
PRINT_ERROR( "Wrong body structure. Internal ERROR\n" );
continue;
}
- B.Add(Co,*(surface->get_TopoDS_Face()));
+ if(surface)
+ B.Add(Co,*(surface->get_TopoDS_Face()));
+ else
+ B.Add(Co,*(shell->get_TopoDS_Shell()));
continue;
}
@@ -969,13 +972,6 @@
}
}
- //Add standalone shells to export BRep file
- for (i = 0; i < ShellList->size(); i++)
- {
- TopoDS_Shell *shell = ShellList->get_and_step()->get_TopoDS_Shell();
- B.Add(Co, *shell);
- }
-
for (i = 0; i < OCC_surfaces.size(); i++)
{
TopoDS_Face *face = OCC_surfaces.get_and_step()->get_TopoDS_Face();
@@ -1079,7 +1075,11 @@
}
for (Ex.Init(aShape, TopAbs_SHELL, TopAbs_SOLID); Ex.More(); Ex.Next())
- populate_topology_bridge(TopoDS::Shell(Ex.Current()), CUBIT_TRUE);
+ {
+ OCCShell* shell =
+ populate_topology_bridge(TopoDS::Shell(Ex.Current()), CUBIT_TRUE);
+ tblist.append(shell->my_body());
+ }
for (Ex.Init(aShape, TopAbs_FACE, TopAbs_SHELL); Ex.More(); Ex.Next())
tblist.append(populate_topology_bridge(TopoDS::Face(Ex.Current()),CUBIT_TRUE));
@@ -1183,8 +1183,10 @@
(TopologyBridge*)shell));
if(standalone)
{
- build_body = CUBIT_TRUE;
- ShellList->append(shell);
+ OCCLump* lump = new OCCLump(NULL, NULL, shell);
+ OCCBody* body = new OCCBody(NULL, CUBIT_FALSE, NULL, shell);
+ shell->set_body(body);
+ shell->set_lump(lump);
}
}
else
@@ -1423,6 +1425,14 @@
return delete_solid_model_entities(occ_surface);
}
+ OCCShell* occ_shell = occ_body->shell();
+ if(occ_shell)
+ {
+ delete occ_shell->my_body();
+ delete occ_shell->my_lump();
+ return unhook_ShellSM_from_OCC(occ_shell);
+ }
+
DLIList<Lump*> lumps = occ_body->lumps();
for(int i =0; i < lumps.size(); i++)
{
@@ -1566,7 +1576,6 @@
Surface* surface = CAST_TO(children.get_and_step(), Surface);
delete_solid_model_entities(surface);
}
- ShellList->remove(CAST_TO(shell, OCCShell));
delete Shell;
delete shell;
return CUBIT_SUCCESS;
Modified: cgm/trunk/geom/OCC/OCCQueryEngine.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCQueryEngine.hpp 2008-03-12 18:04:16 UTC (rev 1642)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.hpp 2008-03-12 18:45:10 UTC (rev 1643)
@@ -346,7 +346,6 @@
Point* populate_topology_bridge(TopoDS_Vertex aShape);
DLIList<OCCBody*> *BodyList ;
- DLIList<OCCShell*> *ShellList; //standalone shell list
DLIList<OCCSurface*> *SurfaceList ;
DLIList<OCCLoop*> *WireList; //standalone wire list
DLIList<OCCCurve*> *CurveList ;
Modified: cgm/trunk/geom/OCC/OCCShell.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCShell.hpp 2008-03-12 18:04:16 UTC (rev 1642)
+++ cgm/trunk/geom/OCC/OCCShell.hpp 2008-03-12 18:45:10 UTC (rev 1643)
@@ -50,6 +50,11 @@
TopoDS_Shell* get_TopoDS_Shell() {return myTopoDSShell;}
void set_TopoDS_Shell(TopoDS_Shell shell){*myTopoDSShell = shell;}
+ OCCLump* my_lump() {return myLump;}
+ OCCBody* my_body() {return myBody;}
+ void set_lump(OCCLump* lump) {myLump = lump;}
+ void set_body(OCCBody* body) {myBody = body;}
+
virtual GeometryQueryEngine*
get_geometry_query_engine() const;
//R GeometryQueryEngine*
@@ -107,6 +112,8 @@
private:
TopoDS_Shell *myTopoDSShell;
OCCSurface* mySheetSurface;
+ OCCLump* myLump;
+ OCCBody* myBody;
};
1
0