Py::Object TopoShapeSolidPy::getMass(void) const { GProp_GProps props; BRepGProp::VolumeProperties(getTopoShapePtr()->_Shape, props); double c = props.Mass(); return Py::Float(c); }
//======================================================================= //function : ShapeToDouble //purpose : used by CompareShapes::operator() //======================================================================= std::pair<double, double> GEOMUtils::ShapeToDouble (const TopoDS_Shape& S, bool isOldSorting) { // Computing of CentreOfMass gp_Pnt GPoint; double Len; if (S.ShapeType() == TopAbs_VERTEX) { GPoint = BRep_Tool::Pnt(TopoDS::Vertex(S)); Len = (double)S.Orientation(); } else { GProp_GProps GPr; // BEGIN: fix for Mantis issue 0020842 if (isOldSorting) { BRepGProp::LinearProperties(S, GPr); } else { if (S.ShapeType() == TopAbs_EDGE || S.ShapeType() == TopAbs_WIRE) { BRepGProp::LinearProperties(S, GPr); } else if (S.ShapeType() == TopAbs_FACE || S.ShapeType() == TopAbs_SHELL) { BRepGProp::SurfaceProperties(S, GPr); } else { BRepGProp::VolumeProperties(S, GPr); } } // END: fix for Mantis issue 0020842 GPoint = GPr.CentreOfMass(); Len = GPr.Mass(); } double dMidXYZ = GPoint.X() * 999.0 + GPoint.Y() * 99.0 + GPoint.Z() * 0.9; return std::make_pair(dMidXYZ, Len); }
Py::Object TopoShapeFacePy::getMass(void) const { GProp_GProps props; BRepGProp::SurfaceProperties(getTopoShapePtr()->getShape(), props); double c = props.Mass(); return Py::Float(c); }
void CShape::CalculateVolumeAndCentre() { GProp_GProps System; BRepGProp::VolumeProperties(m_shape, System); m_volume = System.Mass(); m_centre_of_mass = System.CentreOfMass(); m_volume_found = true; }
// Returns the surface area of this fuselage double CCPACSFuselage::GetSurfaceArea(void) { const TopoDS_Shape& fusedSegments = GetLoft()->Shape(); // Calculate surface area GProp_GProps System; BRepGProp::SurfaceProperties(fusedSegments, System); double myArea = System.Mass(); return myArea; }
// Returns the volume of this fuselage double CCPACSFuselage::GetVolume(void) { const TopoDS_Shape& fusedSegments = GetLoft()->Shape(); // Calculate volume GProp_GProps System; BRepGProp::VolumeProperties(fusedSegments, System); double myVolume = System.Mass(); return myVolume; }
TEST(BRepGPropTestSuite, testComputeBoxSurface) { // create a box, mixing integers and floats BRepPrimAPI_MakeBox my_box(10.,10.,10.); my_box.Build(); ASSERT_TRUE(my_box.IsDone()); // compute shape properties GProp_GProps prop; // the surface should be 6 faces*10*10=600 BRepGProp::SurfaceProperties(my_box.Shape(), prop); ASSERT_GT(prop.Mass(),600.-Precision::Confusion()); ASSERT_LT(prop.Mass(),600.+Precision::Confusion()); }
TEST(BRepGPropTestSuite, testComputeBoxVolume) { // create a box, mixing integers and floats BRepPrimAPI_MakeBox my_box(10.,10.,10.); my_box.Build(); ASSERT_TRUE(my_box.IsDone()); // compute shape properties GProp_GProps prop; // a 10*10*10 cube should have a volume of 1000 BRepGProp::VolumeProperties(my_box.Shape(), prop); ASSERT_GT(prop.Mass(),1000.-Precision::Confusion()); ASSERT_LT(prop.Mass(),1001.+Precision::Confusion()); }
TEST(BRepGPropTestSuite, testComputeSphereVolume) { // create a box, mixing integers and floats BRepPrimAPI_MakeSphere sphere(20.); sphere.Build(); ASSERT_TRUE(sphere.IsDone()); // compute shape properties GProp_GProps prop; // a sphere with a radius of 20 should have a volume of // V = 4/3*pi*20*20*20 = 33510.321638291127 BRepGProp::VolumeProperties(sphere.Shape(), prop); ASSERT_GT(prop.Mass(),33510.321638291127-Precision::Confusion()); ASSERT_LT(prop.Mass(),33510.321638291127+Precision::Confusion()); }
bool ChCascadeDoc::GetVolumeProperties(const TopoDS_Shape& mshape, ///< pass the shape here const double density, ///< pass the density here ChVector<>& center_position, ///< get the position center, respect to shape pos. ChVector<>& inertiaXX, ///< get the inertia diagonal terms ChVector<>& inertiaXY, ///< get the inertia extradiagonal terms double& volume, ///< get the volume double& mass ///< get the mass ) { if (mshape.IsNull()) return false; GProp_GProps mprops; GProp_GProps vprops; BRepGProp::VolumeProperties(mshape,mprops); BRepGProp::VolumeProperties(mshape,vprops); mprops.Add(mprops, density); mass = mprops.Mass(); volume = vprops.Mass(); gp_Pnt G = mprops.CentreOfMass (); gp_Mat I = mprops.MatrixOfInertia(); center_position.x = G.X(); center_position.y = G.Y(); center_position.z = G.Z(); inertiaXX.x = I(1,1); inertiaXX.y = I(2,2); inertiaXX.z = I(3,3); inertiaXY.x = I(1,2); inertiaXY.y = I(1,3); inertiaXY.z = I(2,3); return true; }
int main(int argc, char **argv){ TopoDS_Shape shape; BRep_Builder builder; GProp_GProps prop; if (argc < 2) { std::cerr << "Usage: computeSurface file.brep" << std::endl; exit(1); } BRepTools::Read(shape, argv[1], builder); BRepGProp::SurfaceProperties(shape, prop); std::cout << "Total surface of all shapes: " << prop.Mass() << std::endl; return 0; }
bool DrawUtil::isZeroEdge(TopoDS_Edge e) { TopoDS_Vertex vStart = TopExp::FirstVertex(e); TopoDS_Vertex vEnd = TopExp::LastVertex(e); bool result = isSamePoint(vStart,vEnd); if (result) { //closed edge will have same V's but non-zero length GProp_GProps props; BRepGProp::LinearProperties(e, props); double len = props.Mass(); if (len > Precision::Confusion()) { result = false; } } return result; }
//------------------------------------------------------------------------- // Purpose : Find centroid and volume for lumps and shells // // Special Notes : // // Author : Jane Hu // // Creation Date : 11/30/07 //------------------------------------------------------------------------- CubitStatus OCCBody::mass_properties( CubitVector& centroid, double& volume ) { if( myShells.size() == 0 && myLumps.size() == 0) return CUBIT_FAILURE; GProp_GProps myProps; TopoDS_Shape* pshape = myTopoDSShape; if(!pshape || pshape->IsNull())//single lump or shell or surface { DLIList<Lump*> lumps = this->lumps(); if (lumps.size() > 0) pshape = CAST_TO(lumps.get(), OCCLump)->get_TopoDS_Solid(); } if(!pshape || pshape->IsNull()) return CUBIT_FAILURE; BRepGProp::VolumeProperties(*pshape, myProps); volume = myProps.Mass(); gp_Pnt pt = myProps.CentreOfMass(); centroid.set(pt.X(), pt.Y(), pt.Z()); return CUBIT_SUCCESS; }
//======================================================================= //function : SortShapes //purpose : //======================================================================= void GEOMUtils::SortShapes (TopTools_ListOfShape& SL, const Standard_Boolean isOldSorting) { #ifdef STD_SORT_ALGO std::vector<TopoDS_Shape> aShapesVec; aShapesVec.reserve(SL.Extent()); TopTools_ListIteratorOfListOfShape it (SL); for (; it.More(); it.Next()) { aShapesVec.push_back(it.Value()); } SL.Clear(); CompareShapes shComp (isOldSorting); std::stable_sort(aShapesVec.begin(), aShapesVec.end(), shComp); //std::sort(aShapesVec.begin(), aShapesVec.end(), shComp); std::vector<TopoDS_Shape>::const_iterator anIter = aShapesVec.begin(); for (; anIter != aShapesVec.end(); ++anIter) { SL.Append(*anIter); } #else // old implementation Standard_Integer MaxShapes = SL.Extent(); TopTools_Array1OfShape aShapes (1,MaxShapes); TColStd_Array1OfInteger OrderInd(1,MaxShapes); TColStd_Array1OfReal MidXYZ (1,MaxShapes); //X,Y,Z; TColStd_Array1OfReal Length (1,MaxShapes); //X,Y,Z; // Computing of CentreOfMass Standard_Integer Index; GProp_GProps GPr; gp_Pnt GPoint; TopTools_ListIteratorOfListOfShape it(SL); for (Index=1; it.More(); Index++) { TopoDS_Shape S = it.Value(); SL.Remove( it ); // == it.Next() aShapes(Index) = S; OrderInd.SetValue (Index, Index); if (S.ShapeType() == TopAbs_VERTEX) { GPoint = BRep_Tool::Pnt( TopoDS::Vertex( S )); Length.SetValue( Index, (Standard_Real) S.Orientation()); } else { // BEGIN: fix for Mantis issue 0020842 if (isOldSorting) { BRepGProp::LinearProperties (S, GPr); } else { if (S.ShapeType() == TopAbs_EDGE || S.ShapeType() == TopAbs_WIRE) { BRepGProp::LinearProperties (S, GPr); } else if (S.ShapeType() == TopAbs_FACE || S.ShapeType() == TopAbs_SHELL) { BRepGProp::SurfaceProperties(S, GPr); } else { BRepGProp::VolumeProperties(S, GPr); } } // END: fix for Mantis issue 0020842 GPoint = GPr.CentreOfMass(); Length.SetValue(Index, GPr.Mass()); } MidXYZ.SetValue(Index, GPoint.X()*999.0 + GPoint.Y()*99.0 + GPoint.Z()*0.9); //cout << Index << " L: " << Length(Index) << "CG: " << MidXYZ(Index) << endl; } // Sorting Standard_Integer aTemp; Standard_Boolean exchange, Sort = Standard_True; Standard_Real tol = Precision::Confusion(); while (Sort) { Sort = Standard_False; for (Index=1; Index < MaxShapes; Index++) { exchange = Standard_False; Standard_Real dMidXYZ = MidXYZ(OrderInd(Index)) - MidXYZ(OrderInd(Index+1)); Standard_Real dLength = Length(OrderInd(Index)) - Length(OrderInd(Index+1)); if ( dMidXYZ >= tol ) { // cout << "MidXYZ: " << MidXYZ(OrderInd(Index))<< " > " <<MidXYZ(OrderInd(Index+1)) // << " d: " << dMidXYZ << endl; exchange = Standard_True; } else if ( Abs(dMidXYZ) < tol && dLength >= tol ) { // cout << "Length: " << Length(OrderInd(Index))<< " > " <<Length(OrderInd(Index+1)) // << " d: " << dLength << endl; exchange = Standard_True; } else if ( Abs(dMidXYZ) < tol && Abs(dLength) < tol && aShapes(OrderInd(Index)).ShapeType() <= TopAbs_FACE) { // PAL17233 // equal values possible on shapes such as two halves of a sphere and // a membrane inside the sphere Bnd_Box box1,box2; BRepBndLib::Add( aShapes( OrderInd(Index) ), box1 ); if ( box1.IsVoid() ) continue; BRepBndLib::Add( aShapes( OrderInd(Index+1) ), box2 ); Standard_Real dSquareExtent = box1.SquareExtent() - box2.SquareExtent(); if ( dSquareExtent >= tol ) { // cout << "SquareExtent: " << box1.SquareExtent()<<" > "<<box2.SquareExtent() << endl; exchange = Standard_True; } else if ( Abs(dSquareExtent) < tol ) { Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax, val1, val2; box1.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax); val1 = (aXmin+aXmax)*999 + (aYmin+aYmax)*99 + (aZmin+aZmax)*0.9; box2.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax); val2 = (aXmin+aXmax)*999 + (aYmin+aYmax)*99 + (aZmin+aZmax)*0.9; //exchange = val1 > val2; if ((val1 - val2) >= tol) { exchange = Standard_True; } //cout << "box: " << val1<<" > "<<val2 << endl; } } if (exchange) { // cout << "exchange " << Index << " & " << Index+1 << endl; aTemp = OrderInd(Index); OrderInd(Index) = OrderInd(Index+1); OrderInd(Index+1) = aTemp; Sort = Standard_True; } } } for (Index=1; Index <= MaxShapes; Index++) SL.Append( aShapes( OrderInd(Index) )); #endif }
double IfcGeom::face_area(const TopoDS_Face& f) { GProp_GProps prop; BRepGProp::SurfaceProperties(f,prop); return prop.Mass(); }
//---------------------------------------------------------------- // Function: TopoDS_Shape level function to update the core Body // for any Boolean operation of the body. // Author: Jane Hu //---------------------------------------------------------------- CubitStatus OCCBody::update_OCC_entity(TopoDS_Shape& old_shape, TopoDS_Shape& new_shape, BRepBuilderAPI_MakeShape *op, LocOpe_SplitShape* sp) { //set the Shells TopTools_IndexedMapOfShape M; TopExp::MapShapes(old_shape, TopAbs_SOLID, M); TopTools_IndexedMapOfShape M_new; TopExp::MapShapes(new_shape, TopAbs_SOLID, M_new); TopTools_ListOfShape shapes; TopoDS_Shape shape; CubitBoolean updated = CUBIT_FALSE; if(!old_shape.IsNull() && old_shape.ShapeType() == TopAbs_COMPOUND && !new_shape.IsNull() && new_shape.ShapeType() == TopAbs_COMPOUND && !old_shape.IsSame(new_shape)) { //By updating underling solids, shells etc., the old_shape will get changed. //trying to make sure the the number of each entity in the old and new //shapes are the same, which means that nothing is delete, that we can //update the map here. Otherwise, when deleting solids, it'll delete the //the old body and create new body. This is Ok for general boolean operation //except imprint when booleans are called, usually the original body are // supposed to be kept. updated = CUBIT_TRUE; OCCQueryEngine::instance()->update_OCC_map(old_shape, new_shape); } DLIList<int> new_solid_nums; DLIList<int> unfound_nums; for(int ii=1; ii<=M.Extent(); ii++) { TopoDS_Solid solid = TopoDS::Solid(M(ii)); TopTools_ListOfShape shapes; if(op) { shapes.Assign(op->Modified(solid)); if(shapes.Extent() == 0) shapes.Assign(op->Generated(solid)); } else if(sp) shapes.Assign(sp->DescendantShapes(solid)); if (shapes.Extent() == 1) shape = shapes.First(); else if(shapes.Extent() > 1) { //update all attributes first. TopTools_ListIteratorOfListOfShape it; it.Initialize(shapes); for(; it.More(); it.Next()) { shape = it.Value(); OCCQueryEngine::instance()->copy_attributes(solid, shape); } shape = shapes.First(); } else if(op->IsDeleted(solid)) { if (M_new.Extent()== 1 && ii == 1) shape = M_new(1); else if(M_new.Extent()== 1 && ii > 1) shape.Nullify(); else if(M_new.Extent() > 1) { GProp_GProps myProps; BRepGProp::VolumeProperties(solid, myProps); double bf_mass = myProps.Mass(); gp_Pnt old_center = myProps.CentreOfMass(); CubitBoolean found = CUBIT_FALSE; for(int l = 1; l <= M_new.Extent(); l++) { BRepGProp::VolumeProperties(M_new(l), myProps); double af_mass = myProps.Mass(); double dTol = OCCQueryEngine::instance()->get_sme_resabs_tolerance(); if(fabs(bf_mass-af_mass) < dTol) //unchanged { gp_Pnt new_center = myProps.CentreOfMass(); if(new_center.IsEqual(old_center, dTol)) { found = CUBIT_TRUE; shape = M_new(l); new_solid_nums.append(l); break; } } } if(!found) { unfound_nums.append(ii); continue; } } else shape.Nullify(); } else { shape = solid; continue; } if(shapes.Extent() > 0 || (op && op->IsDeleted(solid))) OCCLump::update_OCC_entity(solid, shape, op, sp); } if( unfound_nums.size() == 1 ) { TopoDS_Solid solid = TopoDS::Solid(M(unfound_nums.get())); for(int kk = 1; kk <= M_new.Extent(); kk++) { if(!new_solid_nums.move_to(kk)) { shape = M_new(kk); break; } } OCCLump::update_OCC_entity(solid, shape, op, sp); } else if(unfound_nums.size() > 1) { shape.Nullify(); for(int kk = 1; kk <=unfound_nums.size(); kk++) { TopoDS_Solid solid = TopoDS::Solid(M(unfound_nums.get_and_step())); OCCLump::update_OCC_entity(solid, shape, op, sp); } } if(!old_shape.IsSame(new_shape) && !updated) OCCQueryEngine::instance()->update_OCC_map(old_shape, new_shape); return CUBIT_SUCCESS; }
//---------------------------------------------------------------- // Function: TopoDS_Shape level function to update the core Surface // for any movement or Boolean operation of the body. // Author: Jane Hu //---------------------------------------------------------------- CubitStatus OCCSurface::update_OCC_entity(TopoDS_Face& old_surface, TopoDS_Shape& new_surface, BRepBuilderAPI_MakeShape *op, TopoDS_Vertex* removed_vertex, LocOpe_SplitShape* sp) { //set the Wires TopTools_IndexedMapOfShape M, M2; TopoDS_Shape shape, shape2, shape_edge, shape_vertex; TopExp::MapShapes(old_surface, TopAbs_WIRE, M); TopTools_ListOfShape shapes; BRepFilletAPI_MakeFillet2d* test_op = NULL; for (int ii=1; ii<=M.Extent(); ii++) { TopoDS_Wire wire = TopoDS::Wire(M(ii)); TopTools_ListOfShape shapes; if(op) { test_op = dynamic_cast<BRepFilletAPI_MakeFillet2d*>(op); if(!test_op) shapes.Assign(op->Modified(wire)); if(shapes.Extent() == 0) shapes.Assign(op->Generated(wire)); if(!new_surface.IsNull()) TopExp::MapShapes(new_surface,TopAbs_WIRE, M2); } else if(sp) shapes.Assign(sp->DescendantShapes(wire)); if (shapes.Extent() == 1) { shape = shapes.First(); if(M2.Extent() == 1) { shape2 = TopoDS::Wire(M2(1)); if(!shape.IsSame(shape2)) shape = shape2; } else if(M2.Extent() > 1) shape.Nullify(); } else if(shapes.Extent() > 1) shape.Nullify(); else if(op->IsDeleted(wire) || shapes.Extent() == 0) { TopTools_IndexedMapOfShape M_new; TopExp::MapShapes(new_surface, TopAbs_WIRE, M_new); if (M_new.Extent()== 1) shape = M_new(1); else shape.Nullify(); } else { shape = wire; continue; } //set curves BRepTools_WireExplorer Ex; for(Ex.Init(wire); Ex.More();Ex.Next()) { TopoDS_Edge edge = Ex.Current(); if(op && !test_op) { shapes.Assign(op->Modified(edge)); if(shapes.Extent() == 0) shapes.Assign(op->Generated(edge)); } else if(sp) shapes.Assign(sp->DescendantShapes(edge)); if (shapes.Extent() == 1) { //in fillet creating mothod, one edge could generated a face, so check //it here. TopAbs_ShapeEnum type = shapes.First().TShape()->ShapeType(); if(type != TopAbs_EDGE) shape_edge.Nullify(); else shape_edge = shapes.First(); } else if (shapes.Extent() > 1) { //update all attributes first. TopTools_ListIteratorOfListOfShape it; it.Initialize(shapes); for(; it.More(); it.Next()) { shape_edge = it.Value(); OCCQueryEngine::instance()->copy_attributes(edge, shape_edge); } shape_edge.Nullify(); } else if (op->IsDeleted(edge)) shape_edge.Nullify(); else if (test_op) { if(!test_op->IsModified(edge)) shape_edge = edge; else shape_edge = (test_op->Modified(edge)).First(); } else shape_edge = edge; //update vertex TopoDS_Vertex vertex = Ex.CurrentVertex(); shapes.Clear(); if(test_op) assert(removed_vertex != NULL); if(op && ! test_op ) shapes.Assign(op->Modified(vertex)); else if(sp) shapes.Assign(sp->DescendantShapes(vertex)); if (shapes.Extent() == 1) shape_vertex = shapes.First(); else if(shapes.Extent() > 1) { //update all attributes first. TopTools_ListIteratorOfListOfShape it; it.Initialize(shapes); for(; it.More(); it.Next()) { shape_vertex = it.Value(); OCCQueryEngine::instance()->copy_attributes(vertex, shape_vertex); } shape_vertex.Nullify() ; } else if(op->IsDeleted(vertex) || (test_op && vertex.IsSame( *removed_vertex))) shape_vertex.Nullify() ; else shape_vertex = vertex; if(!vertex.IsSame(shape_vertex) ) OCCQueryEngine::instance()->update_OCC_map(vertex, shape_vertex); if (!edge.IsSame(shape_edge)) OCCQueryEngine::instance()->update_OCC_map(edge, shape_edge); } if (!wire.IsSame(shape)) OCCQueryEngine::instance()->update_OCC_map(wire, shape); } double dTOL = OCCQueryEngine::instance()->get_sme_resabs_tolerance(); if (!old_surface.IsSame(new_surface)) { TopAbs_ShapeEnum shapetype = TopAbs_SHAPE; if(!new_surface.IsNull()) shapetype = new_surface.TShape()->ShapeType(); if(shapetype == TopAbs_FACE || new_surface.IsNull()) OCCQueryEngine::instance()->update_OCC_map(old_surface, new_surface); else { TopTools_IndexedMapOfShape M; TopExp::MapShapes(new_surface, TopAbs_FACE, M); TopoDS_Shape new_shape; if(M.Extent() == 1) new_shape = M(1); else if(M.Extent() > 1) { for(int i = 1; i <= M.Extent(); i++) { GProp_GProps myProps; BRepGProp::SurfaceProperties(old_surface, myProps); double orig_mass = myProps.Mass(); gp_Pnt orig_pnt = myProps.CentreOfMass(); BRepGProp::SurfaceProperties(M(i), myProps); double after_mass = myProps.Mass(); gp_Pnt after_pnt = myProps.CentreOfMass(); if(fabs(-after_mass + orig_mass) <= dTOL && orig_pnt.IsEqual(after_pnt, dTOL)) { new_shape = M(i); break; } } } OCCQueryEngine::instance()->update_OCC_map(old_surface, new_shape); } } return CUBIT_SUCCESS; }
double OCCFace::area() { GProp_GProps prop; BRepGProp::SurfaceProperties(this->getShape(), prop); return prop.Mass(); }
bool Constraint::getPoints(std::vector<Base::Vector3d> &points, std::vector<Base::Vector3d> &normals, int * scale) const { std::vector<App::DocumentObject*> Objects = References.getValues(); std::vector<std::string> SubElements = References.getSubValues(); // Extract geometry from References TopoDS_Shape sh; for (std::size_t i = 0; i < Objects.size(); i++) { App::DocumentObject* obj = Objects[i]; Part::Feature* feat = static_cast<Part::Feature*>(obj); const Part::TopoShape& toposhape = feat->Shape.getShape(); if (toposhape.isNull()) return false; sh = toposhape.getSubShape(SubElements[i].c_str()); if (sh.ShapeType() == TopAbs_VERTEX) { const TopoDS_Vertex& vertex = TopoDS::Vertex(sh); gp_Pnt p = BRep_Tool::Pnt(vertex); points.push_back(Base::Vector3d(p.X(), p.Y(), p.Z())); normals.push_back(NormalDirection.getValue()); //OvG: Scale by whole object mass in case of a vertex GProp_GProps props; BRepGProp::VolumeProperties(toposhape.getShape(), props); double lx = props.Mass(); *scale = this->calcDrawScaleFactor(sqrt(lx)*0.5); //OvG: setup draw scale for constraint } else if (sh.ShapeType() == TopAbs_EDGE) { BRepAdaptor_Curve curve(TopoDS::Edge(sh)); double fp = curve.FirstParameter(); double lp = curve.LastParameter(); GProp_GProps props; BRepGProp::LinearProperties(TopoDS::Edge(sh), props); double l = props.Mass(); // Create points with 10 units distance, but at least one at the beginning and end of the edge int steps; if (l >= 30) //OvG: Increase 10 units distance proportionately to l for larger objects. { *scale = this->calcDrawScaleFactor(l); //OvG: setup draw scale for constraint steps = (int)round(l / (10*( *scale))); steps = steps<3?3:steps; } else if (l >= 20) { steps = (int)round(l / 10); *scale = this->calcDrawScaleFactor(); //OvG: setup draw scale for constraint } else { steps = 1; *scale = this->calcDrawScaleFactor(); //OvG: setup draw scale for constraint } steps = steps>CONSTRAINTSTEPLIMIT?CONSTRAINTSTEPLIMIT:steps; //OvG: Place upper limit on number of steps double step = (lp - fp) / steps; for (int i = 0; i < steps + 1; i++) { gp_Pnt p = curve.Value(i * step); points.push_back(Base::Vector3d(p.X(), p.Y(), p.Z())); normals.push_back(NormalDirection.getValue()); } } else if (sh.ShapeType() == TopAbs_FACE) { TopoDS_Face face = TopoDS::Face(sh); // Surface boundaries BRepAdaptor_Surface surface(face); double ufp = surface.FirstUParameter(); double ulp = surface.LastUParameter(); double vfp = surface.FirstVParameter(); double vlp = surface.LastVParameter(); double l; double lv, lu; // Surface normals BRepGProp_Face props(face); gp_Vec normal; gp_Pnt center; // Get an estimate for the number of arrows by finding the average length of curves Handle(Adaptor3d_HSurface) hsurf; hsurf = new BRepAdaptor_HSurface(surface); Adaptor3d_IsoCurve isoc(hsurf); try { isoc.Load(GeomAbs_IsoU, ufp); l = GCPnts_AbscissaPoint::Length(isoc, Precision::Confusion()); } catch (const Standard_Failure&) { gp_Pnt p1 = hsurf->Value(ufp, vfp); gp_Pnt p2 = hsurf->Value(ufp, vlp); l = p1.Distance(p2); } try { isoc.Load(GeomAbs_IsoU, ulp); lv = (l + GCPnts_AbscissaPoint::Length(isoc, Precision::Confusion()))/2.0; } catch (const Standard_Failure&) { gp_Pnt p1 = hsurf->Value(ulp, vfp); gp_Pnt p2 = hsurf->Value(ulp, vlp); lv = (l + p1.Distance(p2))/2.0; } try { isoc.Load(GeomAbs_IsoV, vfp); l = GCPnts_AbscissaPoint::Length(isoc, Precision::Confusion()); } catch (const Standard_Failure&) { gp_Pnt p1 = hsurf->Value(ufp, vfp); gp_Pnt p2 = hsurf->Value(ulp, vfp); l = p1.Distance(p2); } try { isoc.Load(GeomAbs_IsoV, vlp); lu = (l + GCPnts_AbscissaPoint::Length(isoc, Precision::Confusion()))/2.0; } catch (const Standard_Failure&) { gp_Pnt p1 = hsurf->Value(ufp, vlp); gp_Pnt p2 = hsurf->Value(ulp, vlp); lu = (l + p1.Distance(p2))/2.0; } int stepsv; if (lv >= 30) //OvG: Increase 10 units distance proportionately to lv for larger objects. { *scale = this->calcDrawScaleFactor(lv,lu); //OvG: setup draw scale for constraint stepsv = (int)round(lv / (10*( *scale))); stepsv = stepsv<3?3:stepsv; } else if (lv >= 20.0) { stepsv = (int)round(lv / 10); *scale = this->calcDrawScaleFactor(); //OvG: setup draw scale for constraint } else { stepsv = 2; // Minimum of three arrows to ensure (as much as possible) that at least one is displayed *scale = this->calcDrawScaleFactor(); //OvG: setup draw scale for constraint } stepsv = stepsv>CONSTRAINTSTEPLIMIT?CONSTRAINTSTEPLIMIT:stepsv; //OvG: Place upper limit on number of steps int stepsu; if (lu >= 30) //OvG: Increase 10 units distance proportionately to lu for larger objects. { *scale = this->calcDrawScaleFactor(lv,lu); //OvG: setup draw scale for constraint stepsu = (int)round(lu / (10*( *scale))); stepsu = stepsu<3?3:stepsu; } else if (lu >= 20.0) { stepsu = (int)round(lu / 10); *scale = this->calcDrawScaleFactor(); //OvG: setup draw scale for constraint } else { stepsu = 2; *scale = this->calcDrawScaleFactor(); //OvG: setup draw scale for constraint } stepsu = stepsu>CONSTRAINTSTEPLIMIT?CONSTRAINTSTEPLIMIT:stepsu; //OvG: Place upper limit on number of steps double stepv = (vlp - vfp) / stepsv; double stepu = (ulp - ufp) / stepsu; // Create points and normals for (int i = 0; i < stepsv + 1; i++) { for (int j = 0; j < stepsu + 1; j++) { double v = vfp + i * stepv; double u = ufp + j * stepu; gp_Pnt p = surface.Value(u, v); BRepClass_FaceClassifier classifier(face, p, Precision::Confusion()); if (classifier.State() != TopAbs_OUT) { points.push_back(Base::Vector3d(p.X(), p.Y(), p.Z())); props.Normal(u, v,center,normal); normal.Normalize(); normals.push_back(Base::Vector3d(normal.X(), normal.Y(), normal.Z())); } } } } } return true; }
double CFace::Area()const{ GProp_GProps System; BRepGProp::SurfaceProperties(m_topods_face,System); return System.Mass(); }
double GetVolume(TopoDS_Shape shape) { GProp_GProps System; BRepGProp::VolumeProperties(shape, System); return System.Mass(); }
double IfcGeom::shape_volume(const TopoDS_Shape& s) { GProp_GProps prop; BRepGProp::VolumeProperties(s, prop); return prop.Mass(); }
std::vector<TopoDS_Wire> EdgeWalker::sortStrip(std::vector<TopoDS_Wire> fw, bool includeBiggest) { std::vector<TopoDS_Wire> sortedWires = sortWiresBySize(fw,false); //biggest 1st if (!sortedWires.size()) { Base::Console().Log("INFO - DVP::extractFaces - no sorted Wires!\n"); return sortedWires; // might happen in the middle of changes? } //find the largest wire (OuterWire of graph) using bbox Bnd_Box bigBox; if (sortedWires.size() && !sortedWires.front().IsNull()) { BRepBndLib::Add(sortedWires.front(), bigBox); bigBox.SetGap(0.0); } std::vector<std::size_t> toBeChecked; std::vector<TopoDS_Wire>::iterator it = sortedWires.begin() + 1; for (; it != sortedWires.end(); it++) { if (!(*it).IsNull()) { Bnd_Box littleBox; BRepBndLib::Add((*it), littleBox); littleBox.SetGap(0.0); if (bigBox.SquareExtent() > littleBox.SquareExtent()) { break; } else { auto position = std::distance( sortedWires.begin(), it ); //get an index from iterator toBeChecked.push_back(position); } } } //unfortuneately, faces can have same bbox, but not be same size. need to weed out biggest if (toBeChecked.size() == 0) { //nobody had as big a bbox as first element of sortedWires if (!includeBiggest) { sortedWires.erase(sortedWires.begin()); } } else if (toBeChecked.size() > 0) { BRepBuilderAPI_MakeFace mkFace(sortedWires.front()); const TopoDS_Face& face = mkFace.Face(); GProp_GProps props; BRepGProp::SurfaceProperties(face, props); double bigArea = props.Mass(); unsigned int bigIndex = 0; for (unsigned int idx = 0; idx < toBeChecked.size(); idx++) { int iCheck = toBeChecked.at(idx); BRepBuilderAPI_MakeFace mkFace2(sortedWires.at(iCheck)); const TopoDS_Face& face2 = mkFace2.Face(); BRepGProp::SurfaceProperties(face2, props); double area = props.Mass(); if (area > bigArea) { bigArea = area; bigIndex = iCheck; } } if (bigIndex == 0) { //first wire is the biggest if (!includeBiggest) { sortedWires.erase(sortedWires.begin()); } } else { //first wire is not the biggest TopoDS_Wire bigWire = *(sortedWires.begin() + bigIndex); sortedWires.erase(sortedWires.begin() + bigIndex); if (includeBiggest) { sortedWires.insert(sortedWires.begin(),bigWire); //doesn't happen often } } } return sortedWires; }
const bool Constraint::getPoints(std::vector<Base::Vector3d> &points, std::vector<Base::Vector3d> &normals) const { std::vector<App::DocumentObject*> Objects = References.getValues(); std::vector<std::string> SubElements = References.getSubValues(); // Extract geometry from References TopoDS_Shape sh; for (std::size_t i = 0; i < Objects.size(); i++) { App::DocumentObject* obj = Objects[i]; Part::Feature* feat = static_cast<Part::Feature*>(obj); const Part::TopoShape& toposhape = feat->Shape.getShape(); if (toposhape.isNull()) return false; sh = toposhape.getSubShape(SubElements[i].c_str()); if (sh.ShapeType() == TopAbs_VERTEX) { const TopoDS_Vertex& vertex = TopoDS::Vertex(sh); gp_Pnt p = BRep_Tool::Pnt(vertex); points.push_back(Base::Vector3d(p.X(), p.Y(), p.Z())); normals.push_back(NormalDirection.getValue()); } else if (sh.ShapeType() == TopAbs_EDGE) { BRepAdaptor_Curve curve(TopoDS::Edge(sh)); double fp = curve.FirstParameter(); double lp = curve.LastParameter(); GProp_GProps props; BRepGProp::LinearProperties(TopoDS::Edge(sh), props); double l = props.Mass(); // Create points with 10 units distance, but at least one at the beginning and end of the edge int steps; if (l >= 20) steps = (int)round(l / 10); else steps = 1; double step = (lp - fp) / steps; for (int i = 0; i < steps + 1; i++) { gp_Pnt p = curve.Value(i * step); points.push_back(Base::Vector3d(p.X(), p.Y(), p.Z())); normals.push_back(NormalDirection.getValue()); } } else if (sh.ShapeType() == TopAbs_FACE) { TopoDS_Face face = TopoDS::Face(sh); // Surface boundaries BRepAdaptor_Surface surface(face); double ufp = surface.FirstUParameter(); double ulp = surface.LastUParameter(); double vfp = surface.FirstVParameter(); double vlp = surface.LastVParameter(); // Surface normals BRepGProp_Face props(face); gp_Vec normal; gp_Pnt center; // Get an estimate for the number of arrows by finding the average length of curves Handle(Adaptor3d_HSurface) hsurf; hsurf = new BRepAdaptor_HSurface(surface); Adaptor3d_IsoCurve isoc(hsurf, GeomAbs_IsoU, vfp); double l = GCPnts_AbscissaPoint::Length(isoc, Precision::Confusion()); isoc.Load(GeomAbs_IsoU, vlp); double lv = (l + GCPnts_AbscissaPoint::Length(isoc, Precision::Confusion()))/2.0; isoc.Load(GeomAbs_IsoV, ufp); l = GCPnts_AbscissaPoint::Length(isoc, Precision::Confusion()); isoc.Load(GeomAbs_IsoV, ulp); double lu = (l + GCPnts_AbscissaPoint::Length(isoc, Precision::Confusion()))/2.0; int stepsv; if (lv >= 20.0) stepsv = (int)round(lv / 10); else stepsv = 2; // Minimum of three arrows to ensure (as much as possible) that at least one is displayed int stepsu; if (lu >= 20.0) stepsu = (int)round(lu / 10); else stepsu = 2; double stepv = (vlp - vfp) / stepsv; double stepu = (ulp - ufp) / stepsu; // Create points and normals for (int i = 0; i < stepsv + 1; i++) { for (int j = 0; j < stepsu + 1; j++) { double v = vfp + i * stepv; double u = ufp + j * stepu; gp_Pnt p = surface.Value(u, v); BRepClass_FaceClassifier classifier(face, p, Precision::Confusion()); if (classifier.State() != TopAbs_OUT) { points.push_back(Base::Vector3d(p.X(), p.Y(), p.Z())); props.Normal(u, v,center,normal); normal.Normalize(); normals.push_back(Base::Vector3d(normal.X(), normal.Y(), normal.Z())); } } } } } return true; }
bool NETGENPlugin_NETGEN_3D::Evaluate(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape, MapShapeNbElems& aResMap) { int nbtri = 0, nbqua = 0; double fullArea = 0.0; for (TopExp_Explorer exp(aShape, TopAbs_FACE); exp.More(); exp.Next()) { TopoDS_Face F = TopoDS::Face( exp.Current() ); SMESH_subMesh *sm = aMesh.GetSubMesh(F); MapShapeNbElemsItr anIt = aResMap.find(sm); if( anIt==aResMap.end() ) { SMESH_ComputeErrorPtr& smError = sm->GetComputeError(); smError.reset( new SMESH_ComputeError(COMPERR_ALGO_FAILED,"Submesh can not be evaluated",this)); return false; } std::vector<int> aVec = (*anIt).second; nbtri += Max(aVec[SMDSEntity_Triangle],aVec[SMDSEntity_Quad_Triangle]); nbqua += Max(aVec[SMDSEntity_Quadrangle],aVec[SMDSEntity_Quad_Quadrangle]); GProp_GProps G; BRepGProp::SurfaceProperties(F,G); double anArea = G.Mass(); fullArea += anArea; } // collect info from edges int nb0d_e = 0, nb1d_e = 0; bool IsQuadratic = false; bool IsFirst = true; TopTools_MapOfShape tmpMap; for (TopExp_Explorer exp(aShape, TopAbs_EDGE); exp.More(); exp.Next()) { TopoDS_Edge E = TopoDS::Edge(exp.Current()); if( tmpMap.Contains(E) ) continue; tmpMap.Add(E); SMESH_subMesh *aSubMesh = aMesh.GetSubMesh(exp.Current()); MapShapeNbElemsItr anIt = aResMap.find(aSubMesh); if( anIt==aResMap.end() ) { SMESH_ComputeErrorPtr& smError = aSubMesh->GetComputeError(); smError.reset( new SMESH_ComputeError(COMPERR_ALGO_FAILED, "Submesh can not be evaluated",this)); return false; } std::vector<int> aVec = (*anIt).second; nb0d_e += aVec[SMDSEntity_Node]; nb1d_e += Max(aVec[SMDSEntity_Edge],aVec[SMDSEntity_Quad_Edge]); if(IsFirst) { IsQuadratic = (aVec[SMDSEntity_Quad_Edge] > aVec[SMDSEntity_Edge]); IsFirst = false; } } tmpMap.Clear(); double ELen_face = sqrt(2.* ( fullArea/(nbtri+nbqua*2) ) / sqrt(3.0) ); double ELen_vol = pow( 72, 1/6. ) * pow( _maxElementVolume, 1/3. ); double ELen = Min(ELen_vol,ELen_face*2); GProp_GProps G; BRepGProp::VolumeProperties(aShape,G); double aVolume = G.Mass(); double tetrVol = 0.1179*ELen*ELen*ELen; double CoeffQuality = 0.9; int nbVols = (int)aVolume/tetrVol/CoeffQuality; int nb1d_f = (nbtri*3 + nbqua*4 - nb1d_e) / 2; int nb1d_in = (int) ( nbVols*6 - nb1d_e - nb1d_f ) / 5; std::vector<int> aVec(SMDSEntity_Last); for(int i=SMDSEntity_Node; i<SMDSEntity_Last; i++) aVec[i]=0; if( IsQuadratic ) { aVec[SMDSEntity_Node] = nb1d_in/6 + 1 + nb1d_in; aVec[SMDSEntity_Quad_Tetra] = nbVols - nbqua*2; aVec[SMDSEntity_Quad_Pyramid] = nbqua; } else { aVec[SMDSEntity_Node] = nb1d_in/6 + 1; aVec[SMDSEntity_Tetra] = nbVols - nbqua*2; aVec[SMDSEntity_Pyramid] = nbqua; } SMESH_subMesh *sm = aMesh.GetSubMesh(aShape); aResMap.insert(std::make_pair(sm,aVec)); return true; }
//============================================================================= bool NETGENPlugin_Mesher::Evaluate(MapShapeNbElems& aResMap) { #ifdef WNT netgen::MeshingParameters& mparams = netgen::GlobalMeshingParameters(); #else netgen::MeshingParameters& mparams = netgen::mparam; #endif // ------------------------- // Prepare OCC geometry // ------------------------- netgen::OCCGeometry occgeo; list< SMESH_subMesh* > meshedSM; PrepareOCCgeometry( occgeo, _shape, *_mesh, &meshedSM ); bool tooManyElems = false; const int hugeNb = std::numeric_limits<int>::max() / 100; // ---------------- // evaluate 1D // ---------------- // pass 1D simple parameters to NETGEN int nbs = 0; if ( _simpleHyp ) { if ( int nbSeg = _simpleHyp->GetNumberOfSegments() ) { nbs = nbSeg; // nb of segments mparams.segmentsperedge = nbSeg + 0.1; mparams.maxh = occgeo.boundingbox.Diam(); mparams.grading = 0.01; } else { // segment length mparams.segmentsperedge = 1; mparams.maxh = _simpleHyp->GetLocalLength(); } } TopTools_DataMapOfShapeInteger EdgesMap; double fullLen = 0.0; double fullNbSeg = 0; for (TopExp_Explorer exp(_shape, TopAbs_EDGE); exp.More(); exp.Next()) { TopoDS_Edge E = TopoDS::Edge( exp.Current() ); if( EdgesMap.IsBound(E) ) continue; SMESH_subMesh *sm = _mesh->GetSubMesh(E); std::vector<int> aVec(SMDSEntity_Last, 0); double aLen = SMESH_Algo::EdgeLength(E); fullLen += aLen; int nb1d = nbs; tooManyElems = ( aLen/hugeNb > mparams.maxh ); if(nb1d==0 && !tooManyElems) { nb1d = (int)( aLen/mparams.maxh + 1 ); } if ( tooManyElems ) // avoid FPE { aVec[SMDSEntity_Node] = hugeNb; aVec[ mparams.secondorder > 0 ? SMDSEntity_Quad_Edge : SMDSEntity_Edge] = hugeNb; } else { fullNbSeg += nb1d; if( mparams.secondorder > 0 ) { aVec[SMDSEntity_Node] = 2*nb1d - 1; aVec[SMDSEntity_Quad_Edge] = nb1d; } else { aVec[SMDSEntity_Node] = nb1d - 1; aVec[SMDSEntity_Edge] = nb1d; } } aResMap.insert(std::make_pair(sm,aVec)); EdgesMap.Bind(E,nb1d); } // ---------------- // evaluate 2D // ---------------- if ( _simpleHyp ) { if ( double area = _simpleHyp->GetMaxElementArea() ) { // face area mparams.maxh = sqrt(2. * area/sqrt(3.0)); mparams.grading = 0.4; // moderate size growth } else { // length from edges mparams.maxh = fullLen/fullNbSeg; mparams.grading = 0.2; // slow size growth } mparams.maxh = min( mparams.maxh, occgeo.boundingbox.Diam()/2 ); } for (TopExp_Explorer exp(_shape, TopAbs_FACE); exp.More(); exp.Next()) { TopoDS_Face F = TopoDS::Face( exp.Current() ); SMESH_subMesh *sm = _mesh->GetSubMesh(F); GProp_GProps G; BRepGProp::SurfaceProperties(F,G); double anArea = G.Mass(); tooManyElems = tooManyElems || ( anArea/hugeNb > mparams.maxh*mparams.maxh ); int nb1d = 0; if ( !tooManyElems ) for (TopExp_Explorer exp1(F,TopAbs_EDGE); exp1.More(); exp1.Next()) nb1d += EdgesMap.Find(exp1.Current()); int nbFaces = tooManyElems ? hugeNb : int( 4*anArea / mparams.maxh*mparams.maxh*sqrt(3.)); int nbNodes = tooManyElems ? hugeNb : (( nbFaces*3 - (nb1d-1)*2 ) / 6 + 1 ); std::vector<int> aVec(SMDSEntity_Last, 0); if( mparams.secondorder > 0 ) { int nb1d_in = (nbFaces*3 - nb1d) / 2; aVec[SMDSEntity_Node] = nbNodes + nb1d_in; aVec[SMDSEntity_Quad_Triangle] = nbFaces; } else { aVec[SMDSEntity_Node] = nbNodes; aVec[SMDSEntity_Triangle] = nbFaces; } aResMap.insert(std::make_pair(sm,aVec)); } // ---------------- // evaluate 3D // ---------------- if(_isVolume) { // pass 3D simple parameters to NETGEN const NETGENPlugin_SimpleHypothesis_3D* simple3d = dynamic_cast< const NETGENPlugin_SimpleHypothesis_3D* > ( _simpleHyp ); if ( simple3d ) { if ( double vol = simple3d->GetMaxElementVolume() ) { // max volume mparams.maxh = pow( 72, 1/6. ) * pow( vol, 1/3. ); mparams.maxh = min( mparams.maxh, occgeo.boundingbox.Diam()/2 ); } else { // using previous length from faces } mparams.grading = 0.4; } GProp_GProps G; BRepGProp::VolumeProperties(_shape,G); double aVolume = G.Mass(); double tetrVol = 0.1179*mparams.maxh*mparams.maxh*mparams.maxh; tooManyElems = tooManyElems || ( aVolume/hugeNb > tetrVol ); int nbVols = tooManyElems ? hugeNb : int(aVolume/tetrVol); int nb1d_in = int(( nbVols*6 - fullNbSeg ) / 6 ); std::vector<int> aVec(SMDSEntity_Last, 0 ); if ( tooManyElems ) // avoid FPE { aVec[SMDSEntity_Node] = hugeNb; aVec[ mparams.secondorder > 0 ? SMDSEntity_Quad_Tetra : SMDSEntity_Tetra] = hugeNb; } else { if( mparams.secondorder > 0 ) { aVec[SMDSEntity_Node] = nb1d_in/3 + 1 + nb1d_in; aVec[SMDSEntity_Quad_Tetra] = nbVols; } else { aVec[SMDSEntity_Node] = nb1d_in/3 + 1; aVec[SMDSEntity_Tetra] = nbVols; } } SMESH_subMesh *sm = _mesh->GetSubMesh(_shape); aResMap.insert(std::make_pair(sm,aVec)); } return true; }
double OCCWire::length() { GProp_GProps prop; BRepGProp::LinearProperties(this->getWire(), prop); return prop.Mass(); }
//------------------------------------------------------------------------- // Purpose : Returns the area of the Surface // //------------------------------------------------------------------------- double OCCSurface::measure() { GProp_GProps myProps; BRepGProp::SurfaceProperties(*myTopoDSFace, myProps); return myProps.Mass(); }
bool NETGENPlugin_NETGEN_2D_ONLY::Evaluate(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape, MapShapeNbElems& aResMap) { TopoDS_Face F = TopoDS::Face(aShape); if(F.IsNull()) return false; // collect info from edges int nb0d = 0, nb1d = 0; bool IsQuadratic = false; bool IsFirst = true; double fullLen = 0.0; TopTools_MapOfShape tmpMap; for (TopExp_Explorer exp(F, TopAbs_EDGE); exp.More(); exp.Next()) { TopoDS_Edge E = TopoDS::Edge(exp.Current()); if( tmpMap.Contains(E) ) continue; tmpMap.Add(E); SMESH_subMesh *aSubMesh = aMesh.GetSubMesh(exp.Current()); MapShapeNbElemsItr anIt = aResMap.find(aSubMesh); if( anIt==aResMap.end() ) { SMESH_subMesh *sm = aMesh.GetSubMesh(F); SMESH_ComputeErrorPtr& smError = sm->GetComputeError(); smError.reset( new SMESH_ComputeError(COMPERR_ALGO_FAILED,"Submesh can not be evaluated",this)); return false; } std::vector<int> aVec = (*anIt).second; nb0d += aVec[SMDSEntity_Node]; nb1d += Max(aVec[SMDSEntity_Edge],aVec[SMDSEntity_Quad_Edge]); double aLen = SMESH_Algo::EdgeLength(E); fullLen += aLen; if(IsFirst) { IsQuadratic = (aVec[SMDSEntity_Quad_Edge] > aVec[SMDSEntity_Edge]); IsFirst = false; } } tmpMap.Clear(); // compute edge length double ELen = 0; if (_hypLengthFromEdges || (!_hypLengthFromEdges && !_hypMaxElementArea)) { if ( nb1d > 0 ) ELen = fullLen / nb1d; } if ( _hypMaxElementArea ) { double maxArea = _hypMaxElementArea->GetMaxArea(); ELen = sqrt(2. * maxArea/sqrt(3.0)); } GProp_GProps G; BRepGProp::SurfaceProperties(F,G); double anArea = G.Mass(); const int hugeNb = numeric_limits<int>::max()/10; if ( anArea / hugeNb > ELen*ELen ) { SMESH_subMesh *sm = aMesh.GetSubMesh(F); SMESH_ComputeErrorPtr& smError = sm->GetComputeError(); smError.reset( new SMESH_ComputeError(COMPERR_ALGO_FAILED,"Submesh can not be evaluated.\nToo small element length",this)); return false; } int nbFaces = (int) ( anArea / ( ELen*ELen*sqrt(3.) / 4 ) ); int nbNodes = (int) ( ( nbFaces*3 - (nb1d-1)*2 ) / 6 + 1 ); std::vector<int> aVec(SMDSEntity_Last); for(int i=SMDSEntity_Node; i<SMDSEntity_Last; i++) aVec[i]=0; if( IsQuadratic ) { aVec[SMDSEntity_Node] = nbNodes; aVec[SMDSEntity_Quad_Triangle] = nbFaces; } else { aVec[SMDSEntity_Node] = nbNodes; aVec[SMDSEntity_Triangle] = nbFaces; } SMESH_subMesh *sm = aMesh.GetSubMesh(F); aResMap.insert(std::make_pair(sm,aVec)); return true; }