[cgma-dev] r1636 - in cgm/trunk: geom/OCC test
janehu at mcs.anl.gov
janehu at mcs.anl.gov
Wed Mar 5 14:12:56 CST 2008
Author: janehu
Date: 2008-03-05 14:12:56 -0600 (Wed, 05 Mar 2008)
New Revision: 1636
Modified:
cgm/trunk/geom/OCC/OCCCurve.cpp
cgm/trunk/geom/OCC/OCCModifyEngine.cpp
cgm/trunk/geom/OCC/OCCModifyEngine.hpp
cgm/trunk/test/makept.cpp
Log:
Added check for curve intersection before making surface from curve list; Added for point_containment for curve to distinguash inside and on boundary situations; Updated testcases.
Modified: cgm/trunk/geom/OCC/OCCCurve.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCCurve.cpp 2008-03-05 17:24:48 UTC (rev 1635)
+++ cgm/trunk/geom/OCC/OCCCurve.cpp 2008-03-05 20:12:56 UTC (rev 1636)
@@ -878,8 +878,19 @@
CubitPointContainment OCCCurve::point_containment( const CubitVector &point )
{
if (is_position_on(point) == CUBIT_TRUE)
+ {
+ DLIList<OCCPoint*> points;
+ get_points(points);
+ for (int i = 0; i < points.size(); i++)
+ {
+ OCCPoint* pnt = points.get_and_step();
+ CubitVector v = pnt->coordinates();
+ double d = v.distance_between(point);
+ if (d < GEOMETRY_RESABS)
+ return CUBIT_PNT_BOUNDARY;
+ }
return CUBIT_PNT_ON;
-
+ }
return CUBIT_PNT_OFF;
}
@@ -1030,8 +1041,8 @@
GCPnts_QuasiUniformAbscissa distribution1(acurve1, NbPoints);
GCPnts_QuasiUniformAbscissa distribution2(acurve2, NbPoints);
TColgp_Array1OfPnt points(1, 2*NbPoints-1);
- int i = 1;
- for (i; i <= NbPoints; i++)
+ int i;
+ for (i = 1; i <= NbPoints; i++)
{
double u = distribution1.Parameter(i);
gp_Pnt P = myCurve1->Value(u);
Modified: cgm/trunk/geom/OCC/OCCModifyEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-03-05 17:24:48 UTC (rev 1635)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-03-05 20:12:56 UTC (rev 1636)
@@ -662,8 +662,10 @@
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
- //vertices.
+ //need to check that no intersection in the middle of the curves, not at
+ //vertices or out of boundary.
+
+ int count = 0; //intersection point should be the same as curve_list size.
for ( int i = 0 ; i < curve_list.size()-1 ; i++ )
{
for(int j = i+1; j < curve_list.size(); j ++)
@@ -676,12 +678,45 @@
curve_list[j], intscts, bounded, closest);
if(yes_int)
{
- PRINT_ERROR("In OCCModifyEngine::make_Surface\n"
+ //check intscts point should be vertex or outside boundary.
+ if (intscts.size() > 2 )
+ {
+ PRINT_ERROR("In OCCModifyEngine::make_Surface\n"
" Cannot make Surface with intersecting curves.\n");
- return (Surface *)NULL;
+ return (Surface *)NULL;
+ }
+ else
+ {
+ for(int k = 0; k < intscts.size(); k++)
+ {
+ CubitVector *v = intscts.get_and_step();
+ CubitPointContainment is_on = CAST_TO(curve_list[i],OCCCurve)->
+ point_containment(*v);
+ if (is_on == CUBIT_PNT_BOUNDARY)
+ {
+ is_on = CAST_TO(curve_list[j],OCCCurve)->
+ point_containment(*v);
+ if (is_on == CUBIT_PNT_BOUNDARY)
+ count++;
+ }
+ else if(is_on == CUBIT_PNT_INSIDE)
+ {
+ PRINT_ERROR("In OCCModifyEngine::make_Surface\n"
+ " Cannot make Surface with intersecting curves.\n");
+ return (Surface *)NULL;
+ }
+ }
+ }
}
}
}
+
+ if (count > curve_list.size())
+ {
+ PRINT_ERROR("In OCCModifyEngine::make_Surface\n"
+ " Cannot make Surface with intersecting curves.\n");
+ return (Surface *)NULL;
+ }
//sort the curves so they are in order and make closed loop
OCCPoint* start = NULL;
@@ -690,7 +725,7 @@
double tol = OCCQueryEngine::instance()->get_sme_resabs_tolerance();
CubitBoolean new_end = CUBIT_TRUE;
int size = curve_list.size();
- int count = 0;
+ count = 0;
for ( int i = 0 ; i < size ; i++ )
{
for(int j = 0; j < curve_list.size(); j ++)
@@ -871,7 +906,7 @@
error = CUBIT_TRUE;
break;
}
- topo_face = &(made_face.Face());
+ topo_face = new TopoDS_Face(made_face.Face());
}
else
{
@@ -884,7 +919,7 @@
break;
}
- topo_face = &(made_face.Face());
+ topo_face = new TopoDS_Face(made_face.Face());
}
}
else
@@ -896,7 +931,8 @@
break;
}
- topo_face = &(made_face.Face());
+ delete topo_face;
+ topo_face = new TopoDS_Face(made_face.Face());
}
}
@@ -1156,7 +1192,7 @@
BodySM* OCCModifyEngine::prism( double height, int sides, double major,
double minor) const
{
-
+ PRINT_ERROR("Option not supported for OCC based geometry.\n");
return (BodySM*) NULL;
}
@@ -1170,7 +1206,7 @@
BodySM* OCCModifyEngine::pyramid( double height, int sides, double major,
double minor, double top) const
{
- PRINT_ERROR("Option not supported for mesh based geometry.\n");
+ PRINT_ERROR("Option not supported for OCC based geometry.\n");
return (BodySM*) NULL;
}
@@ -1192,7 +1228,7 @@
}
TopoDS_Solid S;
- if(r3 == 0)//elliptical cylinder
+ if(r3 == 0)//elliptical based cylinder
{
gp_Pnt center(0.0, 0.0, 0.0);
gp_Dir main_dir(0.0, 0.0, 1.0);
@@ -1225,7 +1261,11 @@
CUBIT_TRUE);
if (lump == NULL)
+ {
+ PRINT_ERROR("In OCCModifyEngine::cylinder\n"
+ " Cannot create a cylinder for given radii.\n");
return (BodySM*)NULL;
+ }
return CAST_TO(lump, OCCLump)->body();
}
@@ -1248,7 +1288,11 @@
CUBIT_TRUE);
if (lump == NULL)
+ {
+ PRINT_ERROR("In OCCModifyEngine::torus\n"
+ " Cannot create a torus for given radii.\n");
return (BodySM*)NULL;
+ }
return CAST_TO(lump, OCCLump)->body();
}
Modified: cgm/trunk/geom/OCC/OCCModifyEngine.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.hpp 2008-03-05 17:24:48 UTC (rev 1635)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.hpp 2008-03-05 20:12:56 UTC (rev 1636)
@@ -652,6 +652,7 @@
DLIList<BodySM*> &new_bodies,
DLIList<TopologyBridge*>*,
DLIList<TopologyBridge*>* ) const;
+
protected:
const TopoDS_Face* make_TopoDS_Face( GeometryType surface_type,
Modified: cgm/trunk/test/makept.cpp
===================================================================
--- cgm/trunk/test/makept.cpp 2008-03-05 17:24:48 UTC (rev 1635)
+++ cgm/trunk/test/makept.cpp 2008-03-05 20:12:56 UTC (rev 1636)
@@ -109,7 +109,7 @@
char *argv = "./66_shaver3.brep";
CubitStatus status = read_geometry(1, &argv);
if (status == CUBIT_FAILURE) exit(1);
-/*
+
argv = "./62_shaver1.brep";
status = read_geometry(1, &argv);
if (status == CUBIT_FAILURE) exit(1);
@@ -117,7 +117,33 @@
argv = "./72_shaver6.brep";
status = read_geometry(1, &argv);
if (status == CUBIT_FAILURE) exit(1);
-*/
+
+ // test create a Compound body.
+ DLIList<Body*> test_bodies;
+ gti->bodies(test_bodies);
+
+ DLIList<RefVolume*> ref_volume_list;
+ for(int i = 0; i < test_bodies.size(); i++)
+ test_bodies.get_and_step()->ref_volumes(ref_volume_list);
+
+ Body* CompBody = gmti->make_Body(ref_volume_list);
+
+ BodySM* CompBodySM = CompBody->get_body_sm_ptr();
+
+ OCCBody *occ_CompBody = CAST_TO(CompBodySM, OCCBody);
+
+ test_bodies.clean_out();
+ gti->bodies(test_bodies);
+
+ CubitVector vi, vii;
+ vi = CompBody->center_point();
+
+ CubitVector axis(10,0,0);
+
+ gti->translate(CompBody,axis);
+ vi = CompBody->center_point();
+ // After parellel move, center point moved by x (10)
+
CubitVector vector1(10,10,10);
CubitVector vector2(10,-10,10);
DLIList<RefEntity*> free_entities;
@@ -128,13 +154,6 @@
gti->get_free_ref_entities(free_entities);
- //translate the two vertice by (10,10,10) and (20,20,20)
- for(int i = 1; i <= free_entities.size(); i++)
- {
- RefEntity * entity = free_entities.get_and_step();
- gti->translate((BasicTopologyEntity*)entity, i*vector1);
- }
-
CubitStatus rsl = CUBIT_SUCCESS;
DLIList<RefEntity*> ref_entity_list;
int num_ents_exported=0;
@@ -160,11 +179,10 @@
about_spatially_equal(vertex1,vertex2);
//vertex1,vertex2 are not spatially equal.
- CubitVector vi, vii;
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(35, 35, 35) is vertex2 translated
+ //translated by (10,10,10) and vii(30, 10, 30) is vertex2 translated
//by 2*(10,10,10).
//check for body
@@ -183,7 +201,6 @@
BodySM* body = bodies.get()->get_body_sm_ptr();
OCCBody* occ_body = CAST_TO(body, OCCBody);
- CubitVector axis(10,0,0);
gti->reflect(bodies, axis);
vi = bodies.get()->center_point();
// After reflection, only x value should change.
@@ -218,26 +235,35 @@
DLIList<RefFace*> ref_faces;
gti->ref_faces(ref_faces);
- RefFace* ref_face = ref_faces.step_and_get();
+ //RefFace* ref_face = ref_faces.step_and_get();
+ RefFace* ref_face = ref_faces.get();
//make a new refface out of existing refface.
- CubitBoolean extended_from = CUBIT_FALSE;
+ CubitBoolean extended_from = CUBIT_TRUE;
RefFace* new_face = gmti->make_RefFace(ref_face, extended_from);
+ rsl = gti->export_solid_model(ref_entity_list, filename, filetype,
+ num_ents_exported, cubit_version);
+
DLIList<DLIList<RefEdge*>*> ref_edge_loops;
new_face->ref_edge_loops(ref_edge_loops);
DLIList<RefEdge*>* ref_edge_list;
ref_edge_list = ref_edge_loops.get();
+ RefVertex* start = NULL;
+ RefVertex* end = NULL;
for (int i = 0; i < ref_edge_list->size(); i++)
{
RefEdge * edge = ref_edge_list->get_and_step();
double d = edge->measure();
- RefVertex* start = edge->start_vertex();
- RefVertex* end = edge->end_vertex();
+ start = edge->start_vertex();
+ end = edge->end_vertex();
}
+ RefFace* new_face2 = gmti->make_RefFace(PLANE_SURFACE_TYPE,
+ *ref_edge_list, ref_face, CUBIT_TRUE);
+
bodies.clean_out();
gti->bodies(bodies);
//translate the new face by (40,40,40)
@@ -250,8 +276,12 @@
gti->translate(entity, i*vector1);
}
- vi = new_face->center_point();
- //center point shout moved by (40,40,40) compared with the original one below
+ RefVolume* volume = NULL;
+ if ( new_face->get_surface_ptr()->is_closed_in_U())
+ 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
vi = ref_face->center_point();
// center point
More information about the cgma-dev
mailing list