[cgma-dev] r1879 - cgm/trunk/geom/OCC
janehu at mcs.anl.gov
janehu at mcs.anl.gov
Fri Jun 6 14:45:15 CDT 2008
Author: janehu
Date: 2008-06-06 14:45:15 -0500 (Fri, 06 Jun 2008)
New Revision: 1879
Modified:
cgm/trunk/geom/OCC/OCCBody.cpp
cgm/trunk/geom/OCC/OCCBody.hpp
cgm/trunk/geom/OCC/OCCCurve.cpp
cgm/trunk/geom/OCC/OCCLump.cpp
cgm/trunk/geom/OCC/OCCLump.hpp
cgm/trunk/geom/OCC/OCCModifyEngine.cpp
cgm/trunk/geom/OCC/OCCShell.cpp
cgm/trunk/geom/OCC/OCCShell.hpp
cgm/trunk/geom/OCC/OCCSurface.cpp
cgm/trunk/geom/OCC/OCCSurface.hpp
Log:
Added a vertex on surface structure, added split edge or face by point function.
Modified: cgm/trunk/geom/OCC/OCCBody.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCBody.cpp 2008-06-06 14:22:00 UTC (rev 1878)
+++ cgm/trunk/geom/OCC/OCCBody.cpp 2008-06-06 19:45:15 UTC (rev 1879)
@@ -53,6 +53,7 @@
#include "GProp_GProps.hxx"
#include "BRepGProp.hxx"
#include "Standard_Boolean.hxx"
+#include "LocOpe_SplitShape.hxx"
//-------------------------------------------------------------------------
// Purpose : A constructor with a list of lumps that are attached.
//
@@ -400,7 +401,8 @@
//----------------------------------------------------------------
CubitStatus OCCBody::update_OCC_entity(TopoDS_Shape& old_shape,
TopoDS_Shape& new_shape,
- BRepBuilderAPI_MakeShape *op)
+ BRepBuilderAPI_MakeShape *op,
+ LocOpe_SplitShape* sp)
{
//set the Shells
TopTools_IndexedMapOfShape M;
@@ -413,7 +415,11 @@
TopoDS_Solid solid = TopoDS::Solid(M(ii));
TopTools_ListOfShape shapes;
- shapes.Assign(op->Modified(solid));
+ if(op)
+ shapes.Assign(op->Modified(solid));
+ else if(sp)
+ shapes.Assign(sp->DescendantShapes(solid));
+
if (shapes.Extent() == 1)
shape = shapes.First();
@@ -435,8 +441,8 @@
continue;
}
- if(shapes.Extent() > 0 || op->IsDeleted(solid))
- OCCLump::update_OCC_entity(solid, shape, op);
+ if(shapes.Extent() > 0 || (op && op->IsDeleted(solid)))
+ OCCLump::update_OCC_entity(solid, shape, op, sp);
}
if(!old_shape.IsSame(new_shape))
OCCQueryEngine::instance()->update_OCC_map(old_shape, new_shape);
Modified: cgm/trunk/geom/OCC/OCCBody.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCBody.hpp 2008-06-06 14:22:00 UTC (rev 1878)
+++ cgm/trunk/geom/OCC/OCCBody.hpp 2008-06-06 19:45:15 UTC (rev 1879)
@@ -41,6 +41,7 @@
class BRepBuilderAPI_Transform;
class BRepAlgoAPI_BooleanOperation;
class BRepBuilderAPI_MakeShape;
+class LocOpe_SplitShape;
// ********** END FORWARD DECLARATIONS **********
class OCCBody : public BodySM
@@ -181,7 +182,8 @@
static CubitStatus update_OCC_entity(TopoDS_Shape& old_shape,
TopoDS_Shape& new_shape,
- BRepBuilderAPI_MakeShape *op);
+ BRepBuilderAPI_MakeShape *op,
+ LocOpe_SplitShape* sp = NULL );
OCCSurface* my_sheet_surface(){if(IsSheetBody) return mySheetSurface;
return (OCCSurface*) NULL;}
Modified: cgm/trunk/geom/OCC/OCCCurve.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCCurve.cpp 2008-06-06 14:22:00 UTC (rev 1878)
+++ cgm/trunk/geom/OCC/OCCCurve.cpp 2008-06-06 19:45:15 UTC (rev 1879)
@@ -435,7 +435,7 @@
{
BRepAdaptor_Curve acurve(*myTopoDSEdge);
gp_Pnt p(location.x(), location.y(), location.z()), newP(0.0, 0.0, 0.0);
- double newVal=0.0;
+ double newVal=0.0, global_newVal = 0.0;
int i;
BRepLProp_CLProps CLP(acurve, 2, Precision::PConfusion());
Extrema_ExtPC ext(p, acurve, Precision::Approximation());
@@ -443,26 +443,33 @@
for ( i = 1 ; i <= ext.NbExt() ; i++ ) {
if ( ext.IsMin(i) ) {
newVal = ext.Point(i).Parameter();
- newP = ext.Point(i).Value();
- CLP.SetParameter(newVal);
+ if(i == 1)
+ global_newVal = newVal;
+ if(newVal <= global_newVal)
+ {
+ global_newVal = newVal;
+ newP = ext.Point(i).Value();
+ CLP.SetParameter(newVal);
+ }
}
}
}
- closest_location = CubitVector(newP.X(), newP.Y(), newP.Z());
- if (tangent_ptr != NULL) {
+ if(global_newVal < 10^10)
+ {
+ closest_location = CubitVector(newP.X(), newP.Y(), newP.Z());
+ if (tangent_ptr != NULL) {
gp_Dir tangent;
if (CLP.IsTangentDefined()) {
CLP.Tangent(tangent);
*tangent_ptr = CubitVector(tangent.X(), tangent.Y(), tangent.Z());
}
- }
- if (curvature_ptr != NULL)
- get_curvature( location, *curvature_ptr);
+ }
+ if (curvature_ptr != NULL)
+ get_curvature( location, *curvature_ptr);
- if (param != NULL) {
+ if (param != NULL)
*param = newVal;
- }
-
+ }
return CUBIT_SUCCESS;
}
Modified: cgm/trunk/geom/OCC/OCCLump.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCLump.cpp 2008-06-06 14:22:00 UTC (rev 1878)
+++ cgm/trunk/geom/OCC/OCCLump.cpp 2008-06-06 19:45:15 UTC (rev 1879)
@@ -49,6 +49,7 @@
#include "TopExp_Explorer.hxx"
#include "TopoDS.hxx"
#include "BRep_Tool.hxx"
+#include "LocOpe_SplitShape.hxx"
// ********** END CUBIT INCLUDES **********
// ********** BEGIN FORWARD DECLARATIONS **********
@@ -353,7 +354,8 @@
//----------------------------------------------------------------
CubitStatus OCCLump::update_OCC_entity(TopoDS_Solid& old_solid,
TopoDS_Shape& new_shape,
- BRepBuilderAPI_MakeShape *op)
+ BRepBuilderAPI_MakeShape *op,
+ LocOpe_SplitShape* sp)
{
//set the Shells
TopTools_IndexedMapOfShape M;
@@ -375,7 +377,11 @@
TopoDS_Shell shell = TopoDS::Shell(M(ii));
TopTools_ListOfShape shapes;
- shapes.Assign(op->Modified(shell));
+ if (op)
+ shapes.Assign(op->Modified(shell));
+ else if(sp)
+ shapes.Assign(sp->DescendantShapes(shell));
+
if (shapes.Extent() == 1)
shape = shapes.First();
@@ -397,8 +403,8 @@
continue;
}
- if(shapes.Extent() > 0 || op->IsDeleted(shell))
- OCCShell::update_OCC_entity(shell, shape, op);
+ if(shapes.Extent() > 0 || (op && op->IsDeleted(shell)))
+ OCCShell::update_OCC_entity(shell, shape, op, sp);
}
if(!old_solid.IsSame(new_shape))
OCCQueryEngine::instance()->update_OCC_map(old_solid, new_solid);
Modified: cgm/trunk/geom/OCC/OCCLump.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCLump.hpp 2008-06-06 14:22:00 UTC (rev 1878)
+++ cgm/trunk/geom/OCC/OCCLump.hpp 2008-06-06 19:45:15 UTC (rev 1879)
@@ -39,6 +39,7 @@
class BRepBuilderAPI_Transform;
class BRepBuilderAPI_MakeShape;
class BRepAlgoAPI_BooleanOperation;
+class LocOpe_SplitShape;
// ********** END FORWARD DECLARATIONS **********
class OCCLump : public Lump
@@ -157,7 +158,8 @@
BRepAlgoAPI_BooleanOperation *op = NULL);
static CubitStatus update_OCC_entity(TopoDS_Solid& old_shape,
TopoDS_Shape& new_shape,
- BRepBuilderAPI_MakeShape *op);
+ BRepBuilderAPI_MakeShape *op,
+ LocOpe_SplitShape* sp = NULL);
protected:
private:
Modified: cgm/trunk/geom/OCC/OCCModifyEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-06-06 14:22:00 UTC (rev 1878)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-06-06 19:45:15 UTC (rev 1879)
@@ -54,6 +54,7 @@
#include "BRepBuilderAPI_MakeFace.hxx"
#include "BRepBuilderAPI_Sewing.hxx"
#include "BRepBuilderAPI_Copy.hxx"
+#include "LocOpe_SplitShape.hxx"
#include "BRep_Tool.hxx"
#include "BRep_Builder.hxx"
#include "GProp_GProps.hxx"
@@ -2576,6 +2577,9 @@
for(int i = 0; i <BodySM_list.size(); i++)
{
occ_body = CAST_TO(BodySM_list.get_and_step(), OCCBody);
+ if (!occ_body)
+ continue;
+
OCCSurface* surface = occ_body->my_sheet_surface();
OCCShell* shell = occ_body->shell();
if(surface)
@@ -3006,19 +3010,107 @@
//===============================================================================
// Function : imprint
// Member Type: PUBLIC
-// Description: Imprints locations to bodies (for splitting curves or putting
-// hardpoints on surfaces).
+// Description: Imprints locations to bodies (for splitting curves, there's
+// no known ways to put hard points on surfaces in OCC, so I just
+// add free_vertex on OCCSurface definition, mesh should look on
+// this structure).
// Author : Jane Hu
// Date : 06/08
//===============================================================================
-CubitStatus OCCModifyEngine::imprint( DLIList<BodySM*> &/*body_list*/,
- DLIList<CubitVector*> &/*vector_list*/,
- DLIList<BodySM*>& /*new_body_list*/,
- bool keep_old /*keep_old_body*/,
+CubitStatus OCCModifyEngine::imprint( DLIList<BodySM*> &body_list,
+ DLIList<CubitVector*> &vector_list,
+ DLIList<BodySM*>& new_body_list,
+ bool keep_old,
DLIList<TopologyBridge*>*,
DLIList<TopologyBridge*>* ) const
{
- return CUBIT_FAILURE;
+ DLIList<TopoDS_Shape*> shape_list;
+ CubitStatus stat = get_shape_list(body_list, shape_list, keep_old);
+
+ if(!stat)
+ return stat;
+
+ for (int i = 0; i < body_list.size(); i++)
+ {
+ OCCBody* body = CAST_TO(body_list.get_and_step(), OCCBody);
+ TopoDS_Shape* from_shape = shape_list.get_and_step();
+ if (!body)
+ continue;
+ DLIList<OCCSurface*> surfaces;
+ DLIList<OCCCurve*> curves;
+
+ body->get_all_surfaces(surfaces);
+ body->get_all_curves(curves);
+
+ CubitBoolean on_vertex = CUBIT_FALSE;
+ CubitBoolean on_curve = CUBIT_FALSE;
+ for (int j = 0; j < vector_list.size(); j ++)
+ {
+ CubitVector* v = vector_list.get_and_step();
+ for (int k = 0; k < curves.size(); k ++)
+ {
+ OCCCurve* curve = curves.get_and_step();
+ CubitPointContainment pc = curve->point_containment(*v);
+ if(pc == CUBIT_PNT_BOUNDARY)
+ {
+ on_vertex = CUBIT_TRUE;
+ break;
+ }
+
+ else if( pc == CUBIT_PNT_INSIDE)
+ {
+ LocOpe_SplitShape splitor(*from_shape);
+ on_curve = CUBIT_TRUE;
+ TopoDS_Edge edge = *curve->get_TopoDS_Edge();
+ gp_Pnt pt = gp_Pnt(v->x(), v->y(), v->z());
+ TopoDS_Vertex vertex = BRepBuilderAPI_MakeVertex(pt);
+ double param = curve->u_from_position(*v);
+ splitor.Add(vertex, param, edge);
+ TopTools_ListOfShape shapes;
+ shapes.Assign(splitor.DescendantShapes(*from_shape));
+ BRepBuilderAPI_MakeShape* pointor = NULL;
+ if(from_shape->TShape()->ShapeType() ==TopAbs_COMPSOLID)
+ OCCBody::update_OCC_entity(*from_shape, shapes.First(),
+ (BRepBuilderAPI_MakeShape*) NULL, &splitor);
+ else if(shapes.First().TShape()->ShapeType() == TopAbs_SOLID)
+ OCCLump::update_OCC_entity(TopoDS::Solid(*from_shape),
+ shapes.First(),
+ (BRepBuilderAPI_MakeShape*) NULL, &splitor);
+
+ else if(shapes.First().TShape()->ShapeType() == TopAbs_SHELL)
+ OCCShell::update_OCC_entity(TopoDS::Shell(*from_shape),
+ shapes.First(),
+ (BRepBuilderAPI_MakeShape*) NULL, &splitor);
+
+ else if(shapes.First().TShape()->ShapeType() == TopAbs_FACE)
+ OCCSurface::update_OCC_entity(TopoDS::Face(*from_shape),
+ shapes.First(),
+ (BRepBuilderAPI_MakeShape*) NULL, &splitor);
+ break;
+ }
+ }
+ if(on_vertex || on_curve)
+ continue;
+
+ //check possible on surface
+ for(int n = 0; n < surfaces.size(); n ++)
+ {
+ OCCSurface* surface = surfaces.get_and_step();
+ if(!surface->is_position_on(*v))
+ continue;
+
+ CubitPointContainment ps = surface->point_containment(*v);
+ if(ps == CUBIT_PNT_INSIDE)
+ {
+ Point* p = make_Point(*v);
+ if(p)
+ surface->add_hardpoint(CAST_TO(p, OCCPoint));
+ break;
+ }
+ }
+ }
+ }
+ return stat;
}
//===============================================================================
Modified: cgm/trunk/geom/OCC/OCCShell.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCShell.cpp 2008-06-06 14:22:00 UTC (rev 1878)
+++ cgm/trunk/geom/OCC/OCCShell.cpp 2008-06-06 19:45:15 UTC (rev 1879)
@@ -43,6 +43,7 @@
#include "BRepBuilderAPI_Transform.hxx"
#include "BRepAlgoAPI_BooleanOperation.hxx"
#include "BRepBuilderAPI_MakeShape.hxx"
+#include "LocOpe_SplitShape.hxx"
// ********** END CUBIT INCLUDES **********
// ********** BEGIN STATIC DECLARATIONS **********
@@ -260,7 +261,8 @@
//----------------------------------------------------------------
CubitStatus OCCShell::update_OCC_entity(TopoDS_Shell& old_shell,
TopoDS_Shape& new_shell,
- BRepBuilderAPI_MakeShape *op)
+ BRepBuilderAPI_MakeShape *op,
+ LocOpe_SplitShape* sp)
{
//set the surfaces
TopTools_IndexedMapOfShape M;
@@ -270,14 +272,18 @@
for(int ii=1; ii<=M.Extent(); ii++)
{
TopoDS_Face face = TopoDS::Face(M(ii));
- shapes.Assign(op->Modified(face));
+ if (op)
+ shapes.Assign(op->Modified(face));
+ else if(sp)
+ shapes.Assign(sp->DescendantShapes(face));
+
if(shapes.Extent() == 1)
shape = shapes.First();
else
shape.Nullify();
- if(shapes.Extent() > 0 || op->IsDeleted(face))
- OCCSurface::update_OCC_entity(face,shape, op);
+ if(shapes.Extent() > 0 || (op && op->IsDeleted(face)))
+ OCCSurface::update_OCC_entity(face,shape, op, sp);
}
if(!old_shell.IsSame(new_shell))
OCCQueryEngine::instance()->update_OCC_map(old_shell, new_shell);
Modified: cgm/trunk/geom/OCC/OCCShell.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCShell.hpp 2008-06-06 14:22:00 UTC (rev 1878)
+++ cgm/trunk/geom/OCC/OCCShell.hpp 2008-06-06 19:45:15 UTC (rev 1879)
@@ -37,6 +37,7 @@
class BRepBuilderAPI_Transform;
class BRepAlgoAPI_BooleanOperation;
class BRepBuilderAPI_MakeShape;
+class LocOpe_SplitShape;
// ********** END CUBIT INCLUDES **********
class OCCShell : public ShellSM
@@ -122,7 +123,8 @@
double measure(); //area of the shell
static CubitStatus update_OCC_entity(TopoDS_Shell& old_shell,
TopoDS_Shape& new_shell,
- BRepBuilderAPI_MakeShape *op);
+ BRepBuilderAPI_MakeShape *op,
+ LocOpe_SplitShape* sp = NULL);
protected:
private:
Modified: cgm/trunk/geom/OCC/OCCSurface.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCSurface.cpp 2008-06-06 14:22:00 UTC (rev 1878)
+++ cgm/trunk/geom/OCC/OCCSurface.cpp 2008-06-06 19:45:15 UTC (rev 1879)
@@ -47,7 +47,7 @@
#include "BRepBuilderAPI_MakeShape.hxx"
#include "BRepTools_WireExplorer.hxx"
#include "BRep_Tool.hxx"
-
+#include "LocOpe_SplitShape.hxx"
// ********** END CUBIT INCLUDES **********
@@ -831,7 +831,8 @@
//----------------------------------------------------------------
CubitStatus OCCSurface::update_OCC_entity(TopoDS_Face& old_surface,
TopoDS_Shape& new_surface,
- BRepBuilderAPI_MakeShape *op)
+ BRepBuilderAPI_MakeShape *op,
+ LocOpe_SplitShape* sp)
{
//set the Wires
TopTools_IndexedMapOfShape M;
@@ -844,7 +845,11 @@
{
TopoDS_Wire wire = TopoDS::Wire(M(ii));
TopTools_ListOfShape shapes;
- shapes.Assign(op->Modified(wire));
+ if(op)
+ shapes.Assign(op->Modified(wire));
+ else if(sp)
+ shapes.Assign(sp->DescendantShapes(wire));
+
if (shapes.Extent() == 1)
shape = shapes.First();
else if(shapes.Extent() > 1)
@@ -870,7 +875,11 @@
for(Ex.Init(wire); Ex.More();Ex.Next())
{
TopoDS_Edge edge = Ex.Current();
- shapes.Assign(op->Modified(edge));
+ if(op)
+ shapes.Assign(op->Modified(edge));
+ else if(sp)
+ shapes.Assign(sp->DescendantShapes(edge));
+
if (shapes.Extent() == 1)
shape_edge = shapes.First();
else if (shapes.Extent() > 1)
@@ -879,23 +888,21 @@
shape_edge.Nullify();
else
shape_edge = edge;
-/*
- if(wire.Orientation() == TopAbs_REVERSED && !shape_edge.IsNull())
- {
- shape_edge.Orientation(
- shape_edge.Orientation()==TopAbs_FORWARD? TopAbs_REVERSED:TopAbs_FORWARD);
- }
-*/
+
//update vertex
TopoDS_Vertex vertex = Ex.CurrentVertex();
- shapes.Assign(op->Modified(vertex));
+ if(op)
+ shapes.Assign(op->Modified(vertex));
+ else if(sp)
+ shapes.Assign(sp->DescendantShapes(vertex));
+
if (shapes.Extent() == 1)
shape_vertex = shapes.First();
else
shape_vertex.Nullify();
- if(!vertex.IsSame(shape_vertex) && (shapes.Extent() > 0 || op->IsDeleted(vertex)))
+ if(!vertex.IsSame(shape_vertex) && (shapes.Extent() > 0 || (op && op->IsDeleted(vertex))))
OCCQueryEngine::instance()->update_OCC_map(vertex, shape_vertex);
if (!edge.IsSame(shape_edge))
Modified: cgm/trunk/geom/OCC/OCCSurface.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCSurface.hpp 2008-06-06 14:22:00 UTC (rev 1878)
+++ cgm/trunk/geom/OCC/OCCSurface.hpp 2008-06-06 19:45:15 UTC (rev 1879)
@@ -50,6 +50,7 @@
class BRepBuilderAPI_Transform;
class BRepAlgoAPI_BooleanOperation;
class BRepBuilderAPI_MakeShape;
+class LocOpe_SplitShape;
//// class CubitTransformMatrix;
class OCCSurface : public Surface
@@ -64,7 +65,8 @@
static CubitStatus update_OCC_entity(TopoDS_Face& old_surface,
TopoDS_Shape& new_surface,
- BRepBuilderAPI_MakeShape *op);
+ BRepBuilderAPI_MakeShape *op,
+ LocOpe_SplitShape* sp = NULL);
void add_shell(OCCShell* shell) { myShellList.append_unique(shell);}
@@ -72,6 +74,9 @@
void remove_shell(OCCShell* shell) {myShellList.remove(shell);}
void clean_shells(){myShellList.clean_out();}
+ void add_hardpoint(OCCPoint* HardPoint){myHardPoints.append(HardPoint);}
+ void remove_hardpoint(OCCPoint* HardPoint){myHardPoints.remove(HardPoint);}
+
virtual void append_simple_attribute_virt(CubitSimpleAttrib*);
//R void
//I
@@ -433,6 +438,7 @@
OCCShell* myShell;
OCCLump* myLump;
OCCBody* myBody;
+ DLIList<OCCPoint*> myHardPoints;
};
More information about the cgma-dev
mailing list