[cgma-dev] r1831 - in cgm/trunk: geom/OCC test
janehu at mcs.anl.gov
janehu at mcs.anl.gov
Tue May 20 14:20:52 CDT 2008
Author: janehu
Date: 2008-05-20 14:20:52 -0500 (Tue, 20 May 2008)
New Revision: 1831
Modified:
cgm/trunk/geom/OCC/OCCLump.cpp
cgm/trunk/geom/OCC/OCCModifyEngine.cpp
cgm/trunk/test/makept.cpp
Log:
Fixed the infinite loop problem, fixed a bug in making spline.
Modified: cgm/trunk/geom/OCC/OCCLump.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCLump.cpp 2008-05-20 15:23:47 UTC (rev 1830)
+++ cgm/trunk/geom/OCC/OCCLump.cpp 2008-05-20 19:20:52 UTC (rev 1831)
@@ -360,8 +360,11 @@
TopoDS_Shape shape;
TopExp::MapShapes(new_shape, TopAbs_SOLID,M);
CubitBoolean is_null_new_shape = CUBIT_FALSE;
+ TopoDS_Solid new_solid;
if(M.Extent() > 1)
is_null_new_shape = CUBIT_TRUE;
+ else if(M.Extent() == 1 )
+ new_solid = TopoDS::Solid(M(1));
M.Clear();
TopExp::MapShapes(old_solid, TopAbs_SHELL, M);
@@ -397,15 +400,5 @@
if(shapes.Extent() > 0 || op->IsDeleted(shell))
OCCShell::update_OCC_entity(shell, shape, op);
}
- TopoDS_Solid new_solid;
- if(!is_null_new_shape && !op->IsDeleted(old_solid))
- new_solid = TopoDS::Solid(new_shape);
- else if (op->IsDeleted(old_solid))
- {
- M.Clear();
- TopExp::MapShapes(new_shape, TopAbs_SOLID, M);
- if(M.Extent() == 1)
- new_solid = TopoDS::Solid(M(1));
- }
OCCQueryEngine::instance()->update_OCC_map(old_solid, new_solid);
}
Modified: cgm/trunk/geom/OCC/OCCModifyEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-05-20 15:23:47 UTC (rev 1830)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-05-20 19:20:52 UTC (rev 1831)
@@ -266,6 +266,9 @@
return (Curve *)NULL;
}
+ if (curve_type == STRAIGHT_CURVE_TYPE)
+ return make_Curve(curve_type, point1_ptr, point2_ptr, NULL, CUBIT_FORWARD);
+
OCCPoint* occ_point1 = CAST_TO(const_cast<Point*>(point1_ptr), OCCPoint);
OCCPoint* occ_point2 = CAST_TO(const_cast<Point*>(point2_ptr), OCCPoint);
@@ -319,22 +322,12 @@
if(curve_type == SPLINE_CURVE_TYPE)
{
Geom_BezierCurve BezierCurve(points);
- Handle(Geom_Curve) curve_ptr(&BezierCurve);
+ Geom_BezierCurve* curve = new Geom_BezierCurve(BezierCurve);
+ Handle(Geom_BoundedCurve) curve_ptr(curve);
TopoDS_Edge new_edge = BRepBuilderAPI_MakeEdge(curve_ptr);
return OCCQueryEngine::instance()->populate_topology_bridge(new_edge);
}
- else if(curve_type == STRAIGHT_CURVE_TYPE)
- {
- TColgp_Array1OfPnt two_points(1,2);
- two_points.SetValue(1, points.Value(1));
- two_points.SetValue(2, points.Value(size));
- Geom_BezierCurve BezierCurve(two_points);
- Handle(Geom_Curve) curve_ptr(&BezierCurve);
- TopoDS_Edge new_edge = BRepBuilderAPI_MakeEdge(curve_ptr);
- return OCCQueryEngine::instance()->populate_topology_bridge(new_edge);
- }
-
return (Curve*) NULL;
}
@@ -371,9 +364,11 @@
{
assert (point1_ptr != NULL && point2_ptr != NULL);
DLIList<CubitVector*> mid_points;
- CubitVector mid_point = *intermediate_point_ptr;
- if (intermediate_point_ptr != NULL )
+ if (intermediate_point_ptr)
+ {
+ CubitVector mid_point = *intermediate_point_ptr;
mid_points.append(&mid_point);
+ }
CubitVector v1(point1_ptr->coordinates());
CubitVector v2(point2_ptr->coordinates());
@@ -2144,6 +2139,7 @@
if(topo_changed)
{
splitor.Build();
+ topo_changed = CUBIT_FALSE;
if(splitor.IsDone())
{
TopoDS_Shape new_from_shape = splitor.Shape();
@@ -2155,7 +2151,7 @@
{
TopoDS_Solid old_solid = TopoDS::Solid(M(1));
OCCLump::update_OCC_entity(old_solid, new_from_shape, &splitor);
- from_shape = new TopoDS_Shape(old_solid);
+ from_shape = new TopoDS_Shape(new_from_shape);
}
}
@@ -2163,19 +2159,19 @@
{
TopoDS_Solid old_solid = TopoDS::Solid(*from_shape);
OCCLump::update_OCC_entity(old_solid, new_from_shape, &splitor);
- from_shape = new TopoDS_Shape(old_solid);
+ from_shape = new TopoDS_Shape(new_from_shape);
}
else if(from_shape->TShape()->ShapeType() == TopAbs_SHELL)
{
TopoDS_Shell old_shell = TopoDS::Shell(*from_shape);
OCCShell::update_OCC_entity(old_shell,new_from_shape, &splitor);
- from_shape = new TopoDS_Shape(old_shell);
+ from_shape = new TopoDS_Shape(new_from_shape);
}
else if(from_shape->TShape()->ShapeType() == TopAbs_FACE)
{
TopoDS_Face old_face = TopoDS::Face(*from_shape);
OCCSurface::update_OCC_entity(old_face,new_from_shape, &splitor);
- from_shape = new TopoDS_Shape(old_face);
+ from_shape = new TopoDS_Shape(new_from_shape);
}
else //imprinting an edge
Modified: cgm/trunk/test/makept.cpp
===================================================================
--- cgm/trunk/test/makept.cpp 2008-05-20 15:23:47 UTC (rev 1830)
+++ cgm/trunk/test/makept.cpp 2008-05-20 19:20:52 UTC (rev 1831)
@@ -150,13 +150,14 @@
// After parellel move, center point moved by x (10)
CubitVector vector1(10,10,10);
- CubitVector vector2(10,-10,10);
+ CubitVector vector2(-10,-10,10);
+ CubitVector vector3(10, -10, 10);
DLIList<RefEntity*> free_entities;
// Make two vertices.
gmti->make_RefVertex(vector1,5);
gmti->make_RefVertex(vector2,5);
-
+ gmti->make_RefVertex(vector3,5);
gti->get_free_ref_entities(free_entities);
CubitStatus rsl = CUBIT_SUCCESS;
@@ -166,10 +167,8 @@
const char * filename = "point.occ";
const char * filetype = "OCC";
- /*
rsl = gti->export_solid_model(ref_entity_list, filename, filetype,
num_ents_exported, cubit_version);
- */
//check for vertex
DLIList<Body*> bodies;
@@ -179,16 +178,15 @@
gti->get_free_ref_entities(free_entities);
RefVertex* vertex1 = CAST_TO(free_entities.get_and_step(),RefVertex);
- RefVertex* vertex2 = CAST_TO(free_entities.get(),RefVertex);
+ RefVertex* vertex2 = CAST_TO(free_entities.get_and_step(),RefVertex);
+ RefVertex* vertex3 = CAST_TO(free_entities.get(),RefVertex);
CubitBoolean is_equal = gti->
about_spatially_equal(vertex1,vertex2);
//vertex1,vertex2 are not spatially equal.
double d;
gti->entity_entity_distance(vertex1,vertex2,vi, vii,d);
- // distance (d) between vertex1,vertex2. vi (20, 20, 20) is vertex1
- //translated by (10,10,10) and vii(30, 10, 30) is vertex2 translated
- //by 2*(10,10,10).
+ // distance (d) between vertex1,vertex2.
//check for body
d = bodies.get()->measure();
@@ -211,9 +209,10 @@
// After reflection, only x value should change.
gti->scale(CompBody,2);
- vi = bodies.get()->center_point();
+ vi = CompBody->center_point();
// After scale, center point moved by 2 times
+ vi = bodies.get()->center_point();
gti->translate(bodies.get(),axis);
vi = bodies.get()->center_point();
// After parellel move, center point moved by x (10)
@@ -249,6 +248,7 @@
CubitBoolean extended_from = CUBIT_TRUE;
RefFace* new_face = gmti->make_RefFace(ref_face, extended_from);
+ ref_entity_list.clean_out();
rsl = gti->export_solid_model(ref_entity_list, filename, filetype,
num_ents_exported, cubit_version);
@@ -288,7 +288,7 @@
volume = new_face->ref_volume();
else
vi = new_face->center_point();
- //center point should moved by (40,40,40) compared with the original one below
+ //center point should moved by (20,20,20) compared with the original one below
vi = ref_face->center_point();
// center point
@@ -365,13 +365,16 @@
//make all kinds of curves.
CubitVector center_pnt(0,0,10);
DLIList<CubitVector*> list;
- CubitVector center_pnt1(5,6,10);
- CubitVector center_pnt2(5,-6,10);
+ CubitVector center_pnt1(5,8,10);
+ CubitVector center_pnt2(1,2,10);
+ CubitVector center_pnt3(-2,-3.5,10);
list.append(¢er_pnt1);
+ list.append(¢er_pnt2);
list.append(¢er_pnt);
- list.append(¢er_pnt2);
- //RefEdge* new_edge_1 = gmti->make_RefEdge(SPLINE_CURVE_TYPE, vertex1,
- // vertex2, list);
+ list.append(¢er_pnt3);
+ RefEdge* new_edge_1 = gmti->make_RefEdge(SPLINE_CURVE_TYPE, vertex1,
+ vertex2, list);
+ d = new_edge_1->measure();
//straight line
RefEdge* new_edge_2 = gmti->make_RefEdge(STRAIGHT_CURVE_TYPE, vertex1,
@@ -381,30 +384,30 @@
//arc curve
RefEdge* new_edge_3 = gmti->make_RefEdge(ARC_CURVE_TYPE, vertex1,
- vertex2, ¢er_pnt);
+ vertex3, ¢er_pnt);
d = new_edge_3->measure();
new_edge_3->closest_point_trimmed(vi, c_point);
//ellipse curve
RefEdge* new_edge_4 = gmti->make_RefEdge(ELLIPSE_CURVE_TYPE, vertex1,
- vertex2, ¢er_pnt);
+ vertex3, ¢er_pnt);
d = new_edge_4->measure();
new_edge_4->closest_point_trimmed(vi, c_point);
RefEdge* new_edge_5 = gmti->make_RefEdge(ELLIPSE_CURVE_TYPE, vertex1,
- vertex2, ¢er_pnt, CUBIT_REVERSED);
+ vertex3, ¢er_pnt, CUBIT_REVERSED);
d = new_edge_5->measure();
new_edge_5->closest_point_trimmed(vi, c_point);
//PARABOLA_CURVE_TYPE
RefEdge* new_edge_6 = gmti->make_RefEdge(PARABOLA_CURVE_TYPE, vertex1,
- vertex2, ¢er_pnt);
+ vertex3, ¢er_pnt);
d = new_edge_6->measure();
new_edge_6->closest_point_trimmed(vi, c_point);
//HYPERBOLA_CURVE_TYPE
RefEdge* new_edge_7 = gmti->make_RefEdge(HYPERBOLA_CURVE_TYPE, vertex1,
- vertex2, ¢er_pnt);
+ vertex3, ¢er_pnt);
d = new_edge_7->measure();
new_edge_7->closest_point_trimmed(vi, c_point);
More information about the cgma-dev
mailing list