void KameleonInterpolator::initializeCoordinates(){ std::string tmp[] = { "NATIVE", "J2000", "GEI", "GEO", "MAG", "GSE", "GSM", "SM", "RTN", "GSEQ", "HEE", "HAE", "HEEQ"}; std::set<std::string> coords(tmp, tmp + sizeof(tmp) / sizeof(tmp[0])); this->from_coords = coords; std::string tmp2[] = { "J2000", "GEI", "GEO", "MAG", "GSE", "GSM", "SM", "RTN", "GSEQ", "HEE", "HAE", "HEEQ", "HNM" //ENLIL }; std::set<std::string> coords2(tmp2, tmp2 + sizeof(tmp2) / sizeof(tmp2[0])); this->to_coords = coords2; }
void create_testcase_for(IfcHierarchyHelper& file, const EllipsePie& pie, Ifc2x3::IfcTrimmingPreference::IfcTrimmingPreference pref) { const double deg = 1. / 180. * 3.141592653; double flt1[] = {0. , 0. }; double flt2[] = {pie.r1 * cos(pie.t1*deg), pie.r2 * sin(pie.t1*deg)}; double flt3[] = {pie.r1 * cos(pie.t2*deg), pie.r2 * sin(pie.t2*deg)}; std::vector<double> coords1(flt1, flt1 + 2); std::vector<double> coords2(flt2, flt2 + 2); std::vector<double> coords3(flt3, flt3 + 2); Ifc2x3::IfcCartesianPoint* p1 = new Ifc2x3::IfcCartesianPoint(coords1); Ifc2x3::IfcCartesianPoint* p2 = new Ifc2x3::IfcCartesianPoint(coords2); Ifc2x3::IfcCartesianPoint* p3 = new Ifc2x3::IfcCartesianPoint(coords3); Ifc2x3::IfcCartesianPoint::list points(new IfcTemplatedEntityList<Ifc2x3::IfcCartesianPoint>()); points->push(p3); points->push(p1); points->push(p2); file.AddEntities(points->generalize()); Ifc2x3::IfcEllipse* ellipse = new Ifc2x3::IfcEllipse(file.addPlacement2d(), pie.r1, pie.r2); file.AddEntity(ellipse); IfcEntities trim1(new IfcEntityList()); IfcEntities trim2(new IfcEntityList()); if (pref == Ifc2x3::IfcTrimmingPreference::IfcTrimmingPreference_PARAMETER) { trim1->push(new IfcWrite::IfcSelectHelper(pie.t1, Ifc2x3::Type::IfcParameterValue)); trim2->push(new IfcWrite::IfcSelectHelper(pie.t2, Ifc2x3::Type::IfcParameterValue)); } else { trim1->push(p2); trim2->push(p3); } Ifc2x3::IfcTrimmedCurve* trim = new Ifc2x3::IfcTrimmedCurve(ellipse, trim1, trim2, true, pref); file.AddEntity(trim); Ifc2x3::IfcCompositeCurveSegment::list segments(new IfcTemplatedEntityList<Ifc2x3::IfcCompositeCurveSegment>()); Ifc2x3::IfcCompositeCurveSegment* s2 = new Ifc2x3::IfcCompositeCurveSegment(Ifc2x3::IfcTransitionCode::IfcTransitionCode_CONTINUOUS, true, trim); Ifc2x3::IfcPolyline* poly = new Ifc2x3::IfcPolyline(points); file.AddEntity(poly); Ifc2x3::IfcCompositeCurveSegment* s1 = new Ifc2x3::IfcCompositeCurveSegment(Ifc2x3::IfcTransitionCode::IfcTransitionCode_CONTINUOUS, true, poly); segments->push(s1); segments->push(s2); file.AddEntities(segments->generalize()); Ifc2x3::IfcCompositeCurve* ccurve = new Ifc2x3::IfcCompositeCurve(segments, false); Ifc2x3::IfcArbitraryClosedProfileDef* profile = new Ifc2x3::IfcArbitraryClosedProfileDef(Ifc2x3::IfcProfileTypeEnum::IfcProfileType_AREA, null, ccurve); file.AddEntity(ccurve); file.AddEntity(profile); IfcSchema::IfcBuildingElementProxy* product = new IfcSchema::IfcBuildingElementProxy( guid(), 0, S("profile"), null, null, 0, 0, null, null); file.addBuildingProduct(product); product->setOwnerHistory(file.getSingle<IfcSchema::IfcOwnerHistory>()); product->setObjectPlacement(file.addLocalPlacement(200 * i++)); IfcSchema::IfcExtrudedAreaSolid* solid = new IfcSchema::IfcExtrudedAreaSolid(profile, file.addPlacement3d(), file.addTriplet<IfcSchema::IfcDirection>(0, 0, 1), 20.0); file.AddEntity(solid); IfcSchema::IfcRepresentation::list reps (new IfcTemplatedEntityList<IfcSchema::IfcRepresentation>()); IfcSchema::IfcRepresentationItem::list items (new IfcTemplatedEntityList<IfcSchema::IfcRepresentationItem>()); items->push(solid); IfcSchema::IfcShapeRepresentation* rep = new IfcSchema::IfcShapeRepresentation( file.getSingle<IfcSchema::IfcRepresentationContext>(), S("Body"), S("SweptSolid"), items); reps->push(rep); IfcSchema::IfcProductDefinitionShape* shape = new IfcSchema::IfcProductDefinitionShape(0, 0, reps); file.AddEntity(rep); file.AddEntity(shape); product->setRepresentation(shape); }
void Structure0815:: computeCharacteristics ( DynVector& centerOfGravity, double& totalMass, double& totalVolume ) { DynVector zero(_dim, 0.0); centerOfGravity = zero; totalMass = 0.0; totalVolume = 0.0; if (_dim == 2){ DynVector coords0(zero); DynVector coords1(zero); for (int iEdge=0; iEdge < _faces.size()/2; iEdge++){ int index = iEdge * 2; for (int i=0; i<_dim; i++){ coords0[i] = _vertices[_faces[index] * _dim + i]; coords0[i] += _displacements[_faces[index] * _dim + i]; coords1[i] = _vertices[_faces[index+1] * _dim + i]; coords1[i] += _displacements[_faces[index+1] * _dim + i]; } typedef precice::utils::GeometryComputations GeoComp; double area = GeoComp::triangleArea(zero, coords0, coords1); area = std::abs(area); // since it comes out signed from cross-prod totalVolume += area; if (not tarch::la::equals(area, 0.0)){ centerOfGravity += (coords0 + coords1) * area / 3.0; } } } else { assertion1(_dim == 3, _dim); DynVector coords0(zero); DynVector coords1(zero); DynVector coords2(zero); DynVector vec01(zero); DynVector vec02(zero); DynVector vec03(zero); DynVector crossVec(zero); for (int iTriangle=0; iTriangle < _faces.size()/3; iTriangle++){ int index = iTriangle * 3; for (int i=0; i<_dim; i++){ coords0[i] = _vertices[_faces[index] * _dim + i]; coords0[i] += _displacements[_faces[index] * _dim + i]; coords1[i] = _vertices[_faces[index+1] * _dim + i]; coords1[i] += _displacements[_faces[index+1] * _dim + i]; coords2[i] = _vertices[_faces[index+2] * _dim + i]; coords2[i] += _displacements[_faces[index+2] * _dim + i]; } vec01 = coords1; vec01 -= coords0; vec02 = coords2; vec02 -= coords0; vec03 = zero; vec03 -= coords0; crossVec = tarch::la::cross(vec01, vec02, crossVec); double volume = tarch::la::dot(crossVec, vec03) / 6.0; volume = std::abs(volume); totalVolume += volume; if (not tarch::la::equals(volume, 0.0)){ centerOfGravity += (coords0 + coords1 + coords2) * volume / 4.0; } } } totalMass = totalVolume * _density; centerOfGravity /= totalVolume; }